jQuery The first jquery program
jquery We are used to calling it jq
Let’s write the first jq program
Click a button to add text to the div
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>第一个jquery程序</title> <style type="text/css"> #dv{ width:150px; height:150px; border:1px solid red; } </style> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script> //引入js <script> $(function(){ $('#but').click(function(){ $('#dv').html("php中文网"); }); }); </script> </head> <body> <div id="dv"></div><br> <input type="button" value="按钮" id="but"> </body> </html>
Look at the above code: First When we write jq code
we must first write
$(function(){
code block
})
Then we write functional code in the code block