事件绑定
2015-06-10 11:50
274 查看
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:
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:
var btn = document.getElementById("myBtn"); btn.addEventListener("click", function() { alert(this.id); }, false)
相关文章推荐
- 在imp数据库时报错1045
- .net接口作用
- PMC云计算大会再出击 携众厂商高歌猛进
- android Dialog给Activity 传参
- UI控件问题和XCode编译警告和错误解决方法集锦 (持续更新ing)
- 让Git 更好的配置
- c++中的 extern "C"用法
- 方块大动员登陆iOS和Android平台,扫码就可立即体验超流畅的俄罗斯方块手游
- 多线程-NSOperationQueue
- Android快速开发之appBase——(3).详解IHolder和IData
- andrdoid内置视频文件
- 《mysql 必知必会》学习笔记(三)
- WinForm - ListView点击空白事件
- Javascript中的getUTCHours()方法使用详解
- oracle用户创建及权限设置
- html5新增语义化标签
- zsh-替换掉黑白的控制台
- jQuery实现首页图片淡入淡出效果的方法
- .net 跨数据库事务的实现
- TIPC 透明通信协议