跨浏览器的事件处理程序

2017-06-16 17:10:00
admin
原创
328
<!DOCTYPE html>
<html>
<head>
    <title>Cross-Browser Event Handler Example</title>
    <script type="text/javascript" src="EventUtil.js"></script>
</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");
        var handler = function(){
            alert("Clicked");
        };
        EventUtil.addHandler(btn, "click", handler); 
        
        var removeBtn = document.getElementById("myRemoveBtn");
        EventUtil.addHandler(removeBtn, "click", function(){
            EventUtil.removeHandler(btn, "click", handler); 
        });
        
    </script>
</body>
</html>
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227