event.target

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        
        <input type="button" name="mybtn" value="按钮"  />
        
        <script src="js/jquery-1.9.1.js" type="text/javascript"></script>
        <script>
            
             $(document).click(function(e) {
                 console.log(e);
                 console.log(e.target);
                 console.log(e.target.id);
                 //console.log(event.target);
                 //console.log(event.target.id));
            });
        </script>
    </body>
</html>

 

 

在 IE6-8 中,事件模型与标准不同。使用非标准的 element.attachEvent() 方法绑定事件监听器。在该模型中,事件对象有一个 srcElement 属性,等价于target 属性。

function hide(e) {
  // 支持 IE6-8
  var target = e.target || e.srcElement;
  target.style.visibility = 'hidden';
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2021-07-14
相关资源
相似解决方案