麻烦老师检查,另外function(event){}的用法不是很懂
来源:5-2 编程练习
CC陈十一
2019-03-21 15:25:14
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>习题</title> <style> div { width: 300px; height: 300px; border: 1px solid red; text-align: center; line-height: 300px; } </style> </head> <body> <div></div> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <script> //此处写代码 $(document).ready(function(){ $('div').mousemove(function(event){ $(this).text('pageX:'+event.pageX+',pageY:'+event.pageY); }); }); </script> </body> </html>
1回答
同学,你好。
效果实现的不错。event表示事件的真正触发者,event是鼠标事件对象,代表事件的状态,比如事件在其中发生的元素、键盘按键的状态、鼠标的位置、鼠标按钮的状态。
在event中包含了事件触发时的参数,比如click事件的event中包含着.e.pageX,e.pageY,keydown事件中包含着ev.keyCode等,在ie中,event是全局的可以通过window.event来获取,在其他浏览器中都是作为参数传入的。 加油,继续努力。
祝学习愉快!
相似问题