jQuery ???
jQuery Selectors
jQuery ???? ???? HTML ?? ???? ?? ??? ?? ??? ??? ? ????.
jQuery ???
jQuery ???? ???? HTML ?? ???? ?? ??? ?? ??? ??? ? ????.
jQuery ???? ??? ID, ???, ??, ??, ?? ? ?? ???? HTML ??? "??"(?? ??)???. ?? ?? ??? ?? ??? ?? ?? CSS ???? ???? ???.
jQuery? ?? ???? ?? ??($())? ?????.
Element Selector
jQuery ?? ???? ??? ???? ??? ?????.
???? ?? <p> ?? ??:
$("p")
?
???? ??? ???? ?? <p> ??? ?????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>jQuery示例</title> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>這是一個(gè)標(biāo)題</h2> <p>這是一個(gè)段落。</p> <p>這是另一個(gè)段落。</p> <button>點(diǎn)我</button> </body> </html>
#id ???
jQuery #id ???? HTML ??? id ??? ?? ??? ??? ?????.
???? ?? ??? ID? ???? ??? ???? ?? ??? ??? ????? #id ???? ???? ???.
id? ??? ???? ??? ??? ????.
$("#test")
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("#test").hide(); }); }); </script> </head> <body> <h2>好好學(xué)習(xí)</h2> <p>天天向上</p> <p id="test">PHP測(cè)試</p> <button>點(diǎn)我</button> </body> </html>
.class ???
jQuery ??? ???? ??? ????? ??? ?? ? ????.
??? ??? ????: ($ (". Test")
??
??("*") ?? ?? ??
$ (this) ?? HTML ?? ??
$ ("" " p.intro") ?? ??? ??? <p> ??? ?????.
$("p:first") ??????????????????????????????????????????????????????????? ? ?? <p> ?? ???????????????????????????~????????????????????????????????????????????("ul li:first-child") ? <ul> ??? ? ?? <li> ??? ?????.
$("[href] ") href ??? ?? ??? ?????.
$("a [target='_blank']") ?? ?? ?? "_blank"? ??? ?? <a> ??? ?????.
$("a[target! ='_blank']") "_blank" & Lt; a & gt; ??
? ?? ?? ?? ?? ?? ? ?? $ (": Button") ?? ?? ?? = "Button" & lt; ?? & gt; ?? & gt; ??
("tr: event") Tr & gt; $ ("tr: ODD")
jQuery ?? ??? ???? ?? ???? ???? ?? jQuery ??? ?? ?? ??? ? ??? ???? jQuery ??? ??? .js ??? ?????.
?????? jQuery? ??? ? <head> ??? ??? ?? ?????. ??? ??? ?? ??? ??? ???? ?? ? ????(src ??? ?? ?? ??): <head>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script src="my_jquery_functions.js"></script>
</head>