abstract:事件方法会触发匹配元素的事件,或将函数绑定到所有匹配元素的某个事件。例如:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jquery的事件</title> <script type=&q
事件方法会触发匹配元素的事件,或将函数绑定到所有匹配元素的某个事件。
例如:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jquery的事件</title> <script type="text/javascript" src="jquery-3.3.1.min.js"></script> </head> <body> <script type="text/javascript" > $(document).ready(function(){ $(document).mousemove(function(id){ $(".mouseid span").text("x为:"+id.pageX+"y为:"+id.pageY) //mousemove为指针在制定的元素上移动时会触发事件;pageX(),pageY():鼠标指针的位置,相对于文档的左边缘/上边缘,aa.pageY中aa必需要 }) a=0; $(window).resize(function(id){ //resize()当调整当前浏览器窗口大小时触发事件 $(".winsize span").text(a+=1)//每改变一次a加1 }) }) </script> <div> 目前鼠标的位置是:<span></span> </div> <div> 页面被调整的次数:<span></span> </div </body> </html>