jQuery中的HelloWorld

xiaoxiao2021-02-27  576

首先要先下载jQuery的库 这里用的是 jquery-1.12.4.min.js

代码:

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="jquery-1.12.4.min.js"></script> <script type="text/javascript"> //$(function(){})相当于window.onload,代码写在{}之间 $(function() { //1.选取button:$("button") //2.为button 添加onclike 相应函数 $("button").click(function(){}) //代码写在function的{}里 $("button").click(function(){ //3.弹出helloworld alert("helloworld"); }); }) </script> </head> <body> <button>ClickMe</button> </body> </html>

运行结果`

转载请注明原文地址: https://www.6miu.com/read-1394.html

最新回复(0)