• 周日. 5月 26th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

js对整个div进行侦听,并通过设定值判断是哪个按钮的点击事件

admin

11月 28, 2021

其中.btns代表在总体的div中定义的classdata-id为在button中定义的标记字符

<div class="btns">
        <div class="btn-switch active-map" data-id="0">1</div>
        <div class="btn-switch" data-id="1">2</div>
        <div class="btn-switch" data-id="2">3</div>
  </div>
 
document.querySelector(".btns").addEventListener("click", function(event) {
var id = event.target.getAttribute("data-id");
}

《js对整个div进行侦听,并通过设定值判断是哪个按钮的点击事件》有一个想法
  1. Wow, marvelous blog structure! How long have you been blogging for?
    you make running a blog look easy. The full glance of your web
    site is fantastic, as smartly as the content! You can see similar
    here ecommerce

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注