码迷,mamicode.com
首页 > 其他好文 > 详细

事件绑定

时间:2015-06-10 13:52:55      阅读:95      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!