event.srcElement

2017-06-16 17:23:00
admin
原创
422
<!DOCTYPE html>
<html>
<head>
    <title>IE Event Object Example</title>
</head>
<body>
    <input type="button" id="myBtn" value="Click Me" />
    <p>This example only works in Internet Explorer.</p>
    <script type="text/javascript">
        var btn = document.getElementById("myBtn");
        btn.onclick = function(){
            alert(window.event.srcElement === this);      //true
        };
        
        btn.attachEvent("onclick", function(event){
            alert(event.srcElement === this);             //false
        });
      
    </script>
</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络