DOM0 级事件处理程序

2017-06-16 17:00:00
admin
原创
620
<!DOCTYPE html>
<html>
<head>
    <title>DOM Level 0 Event Handler Example</title>
</head>
<body>
    <input type="button" id="myBtn" value="Click Me" />
    <input type="button" id="myRemoveBtn" value="Remove Event Handler" />
    <script type="text/javascript">
        var btn = document.getElementById("myBtn");
        btn.onclick = function(){
            alert(this.id);
        };
        
        var removeBtn = document.getElementById("myRemoveBtn");
        removeBtn.onclick = function(){
            btn.onclick = null;
        };
    </script>
</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络