onmousedown,onmouseup,onclick同时应用于一个标签节点Element
2016-05-08 14:07
369 查看
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>鼠标按下时更换字体背景色,抬起时还原默认颜色。</title> <style> .xuexi{width:200px;height:120px;background:#abcdef;border:1px solid green;} </style> <script> function downClick(){ console.log("onmousedown"); var woaixuexi=document.getElementById("woaixuexi"); woaixuexi.style.background="red"; } function upClick(){ console.log("onmouseup"); var woaixuexi=document.getElementById("woaixuexi"); woaixuexi.style.background="blue"; } function reClick(){ console.log("onclick"); var woaixuexi = document.getElementById("woaixuexi"); woaixuexi.style.background="green"; } </script> </head> <body> <div id="woaixuexi" onmousedown="downClick();" onmouseup="upClick();" onclick="reClick();" class="xuexi"></div> </body> </html>
代码分析:
1、当onmousedown,onmouseup,onclick同时作用在一个元素节点上时,执行的顺序依次为onmousedown,onmouseup,onclick;
2、onmousedown:是在鼠标按下之后触发的事件;
onmouseup:鼠标抬起时触发的事件;
onclick:鼠标点击后触发的事件(包含了两个动作,及按下与抬起两个过程。)onclick = onmousedown + onmouseup;
相关文章推荐
- 我的目标
- 常用排序算法总结(三)
- linux curl命令详解
- java设计模式之模板模式
- Ext.grid.Panel中stateId的作用
- poj1068Parencodings
- HashMap实现原理分析
- Android Gradle Plugin指南(二)——基本项目
- java中的集合类(Collection)中的Set
- Search in Rotated Sorted Array
- Linux date命令详解
- NetAnalyzer2016使用方法
- 理解面向对象编程(二)-用例图及特征
- 多波束EM122安装纪实(一)总览
- String Date Calendar之间的转换
- 读《深度探索C++对象模型》之分层继承对于内存布局的影响
- 几种常见排序算法
- Android 导入第三方jar包
- GitHub版本控制器使用
- 20145208 实验五 Java网络编程