首页 > 其他 > 详细

事件绑定

时间:2015-06-10 13:52:14      阅读:249      评论:0      收藏:0      [点我收藏+]

addEventListener() and removeEventListener()

These methods exist on all DOM nodes and accept three arguments: the event name to handle, the event handler function, and a Boolean value indicating whether to call the event handler during the capture phase (true) or during the bubble phase (false);

to add an event handler for the click event on a button, you can use the following code:

1 var btn = document.getElementById("myBtn");
2 btn.addEventListener("click", function() {
3     alert(this.id);
4 }, false)

 

事件绑定

原文:http://www.cnblogs.com/linxd/p/4565645.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!