基本語法:$(selector).action()
$:該符號定義jQuery
selector:查詢html元素
action:對此元素的操做
實例javascript
<html> <head> <meta content="text/html; charset=UTF-8"> <script type="text/javascript" src="jquery-3.1.1.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>If you click on me, I will disappear.</p> </body> </html>
文檔就緒函數html
$(document).ready(function(){ }
jQuery全部的函數都必須位於ready函數中,該函數的做用是:文檔徹底加載完。java