1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> div{ width: 300px; height: 300px; background-color: skyblue; } </style> </head> <body> <input type="button" value="单击事件" id="i1"/> <input type="button" value="双击事件" id="i2"/> <input type="button" value="按钮按下事件" id="i3"/> <input type="button" value="鼠标右键" id="i4"/> <input type="button" value="鼠标按钮抬起事件" id="i5"/> <div id="div1">模拟鼠标进出以及鼠标移动事件</div> </body> </html> <script type="text/javascript">
i1.onclick=function(){ var ev=event||e; console.log(ev); console.log("单击事件"); } i2.ondblclick=function(){ console.log(event); console.log("双击事件"); } i3.onmousedown=function(){ console.log("鼠标按钮按下"); } i5.onmouseup=function(){ console.log("鼠标按钮抬起"); } i4.oncontextmenu=function(){ console.log("鼠标右键"); }
div1.onmousemove=function(){ console.log("鼠标移动") }
div1.onmouseover=function(){ console.log("over鼠标进入") } div1.onmouseout=function(){ console.log("out鼠标离开") } div1.onmousewheel=function(){ console.log("滚轮滚动"); } div1.onmousedown=function(){ console.log(event.button); if(event.button==0){ console.log("左键"); } if(event.button==1){ console.log("滚轮键"); } if(event.button==2){ console.log("右键"); } } </script>
|