代码如下:
<!DOCTYPE html> <html> <head> <title>jquery事件</title> </head> <script type="text/javascript" src='./js/jquery-3.2.1.min.js'></script> <script type="text/javascript"> $(document).ready(function(){ // $("#p1").mouseenter(function(){ // alert('您的鼠标移到了 id="p1" 的元素上!'); // }); $("#p1").click(function() { alert('你点击了。。。'); }); }); </script> <body> <p id="p1">试试能点击么?</p> </body> </html>
$(document).ready()
$(document).ready() 方法允许我们在文档完全加载完后执行函数。<必须写,不然不能实现>
相关函数: