<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta lang="zh"> <script src="js/jquery-3.3.1.js"></script> <script type="text/javascript"> $(document).ready(function () { alert('hello world'); }); $(document).ready(function () { $("button").click(function () { alert('no click me') ; }); }) </script> </head> <body> <button type="button">click me</button> </body> </html>
javascript反正坑多,莫名其妙的就错了。
注意:
1.jquery包要正确,
2.jquery语句,尽量写在$(document).ready()里面