һ
 ע

QQ¼

ֻһٿʼ

ƼĶ

+
̳ WEBҳǰ뿪 ǰ̨ű

jQueryѡܽ

[]
6050 happy175 2013-10-14 12:46:53
| ʾȫ¥
1F

ϵ½עᣬύѣø๦ܣϴزIJޣ

Ҫ ¼ ſػ鿴ûʺţע  

x
jquery ѡν֮ǿޱȣ򵥵ܽһ³õԪزҷ

$("#myELement")    ѡidֵmyElementԪأidֵظĵֻһidֵmyElementԵõΨһԪ
$("div")           ѡеdivǩԪأdivԪ
$(".myClass")      ѡʹmyClasscssԪ
$("*")             ѡĵееԪأöֵѡʽѡ$("#myELement,div,.myclass")

ѡ


$("form input")         ѡеformԪеinputԪ
$("#main > *")          ѡidֵΪmainеԪ
$("label + input")     ѡеlabelԪصһinputԪؽڵ㣬ѡصlabelǩֱӸһinputǩinputǩԪ
$("#prev ~ div")       ͬѡѡصΪidΪprevıǩԪصеͬһԪصdivǩ

ѡ


$("tr:first")               ѡtrԪصĵһ
$("tr:last")                ѡtrԪصһ
$("input:not(:checked) + span")   

˵checkedѡеinputԪ

$("tr:even")               ѡеtrԪصĵ024... ...Ԫأע⣺ΪѡĶԪʱΪ飬Ǵ0ʼ

$("tr:odd")                ѡеtrԪصĵ135... ...Ԫ
$("td:eq(2)")             ѡеtdԪΪ2ǸtdԪ
$("td:gt(4)")             ѡtdԪŴ4tdԪ
$("td:ll(4)")              ѡtdԪС4еtdԪ
$(":header")
$("div:animated")


ݹѡ

$("div:contains('John')") ѡdivкJohnıԪ
$("td:empty")           ѡеΪգҲıڵ㣩tdԪص
$("div:has(p)")        ѡкpǩdivԪ
$("td:parent")          ѡеtdΪڵԪ


ӻѡ

$("div:hidden")        ѡеıhiddendivԪ
$("div:visible")        ѡеĿӻdivԪ


Թѡ

$("div[id]")              ѡкidԵdivԪ
$("input[name='newsletter']")    ѡеnameԵ'newsletter'inputԪ

$("input[name!='newsletter']") ѡеnameԲ'newsletter'inputԪ

$("input[name^='news']")         ѡеname'news'ͷinputԪ
$("input[name$='news']")         ѡеname'news'βinputԪ
$("input[name*='man']")          ѡеname԰'news'inputԪ

$("input[id][name$='man']")    ʹöԽѡ񣬸ѡǵõеĺidԲômanβԪ

Ԫعѡ

$("ul li:nth-child(2)"),$("ul li:nth-child(odd)"),$("ul li:nth-child(3n + 1)")

$("div span:first-child")          еdivԪصĵһӽڵ
$("div span:last-child")           еdivԪصһڵ
$("div button:only-child")       еdivֻΨһһӽڵӽڵ

Ԫѡ

$(":input")                  ѡеıԪأinput, textarea, select button

$(":text")                     ѡеtext inputԪ
$(":password")           ѡеpassword inputԪ
$(":radio")                   ѡеradio inputԪ
$(":checkbox")            ѡеcheckbox inputԪ
$(":submit")               ѡеsubmit inputԪ
$(":image")                 ѡеimage inputԪ
$(":reset")                   ѡеreset inputԪ
$(":button")                ѡеbutton inputԪ
$(":file")                     ѡеfile inputԪ
$(":hidden")               ѡΪhiddeninputԪػ

Ԫعѡ

$(":enabled")             ѡеĿɲıԪ
$(":disabled")            ѡеIJɲıԪ
$(":checked")            ѡеıcheckedıԪ
$("select option:selected") ѡеselect ԪбselectedԪ

  

ѡȡһ name ΪS_03_22input textһtdtextֵ
$(input[@ name =S_03_22]).parent().prev().text()

ԡS_ʼҲԡ_Rβ
$(input[@ name ^='S_']).not([@ name $='_R'])

һΪ radio_01radioѡֵ
$(input[@ name =radio_01][@checked]).val();  


$("A B") AԪӽڵ㣬ֱӽڵ
$("A>B") AԪֱӽڵ
$("A+B") AԪغֵܽڵ㣬ֱӽڵ
$("A~B") AԪغֵܽڵ㣬ֱӽڵ

1. $("A B") AԪӽڵ㣬ֱӽڵ

ӣҵе input Ԫ

HTML :


  1. <div class="line number108 index107 alt1"><code class="javascript plain"><form></code></div><div class="line number109 index108 alt2"><code class="javascript plain"><label>Name:</label></code></div><div class="line number110 index109 alt1"><code class="javascript plain"><input name=</code><code class="javascript string">"name"</code> <code class="javascript plain">/></code></div><div class="line number111 index110 alt2"><code class="javascript plain"><fieldset></code></div><div class="line number112 index111 alt1"><code class="javascript spaces">      </code><code class="javascript plain"><label>Newsletter:</label></code></div><div class="line number113 index112 alt2"><code class="javascript spaces">      </code><code class="javascript plain"><input name=</code><code class="javascript string">"newsletter"</code> <code class="javascript plain">/></code></div><div class="line number114 index113 alt1"><code class="javascript plain"></fieldset></code></div><div class="line number115 index114 alt2"><code class="javascript plain"></form></code></div><div class="line number116 index115 alt1"><code class="javascript plain"><input name=</code><code class="javascript string">"none"</code> <code class="javascript plain">/> </code></div>
ƴ


jQuery :

  1. <code class="javascript plain">$(</code><code class="javascript string">"form input"</code><code class="javascript plain">) </code>
ƴ


:

  1. <code class="javascript plain">[ <input name=</code><code class="javascript string">"name"</code> <code class="javascript plain">/>, <input name=</code><code class="javascript string">"newsletter"</code> <code class="javascript plain">/> ] </code>
ƴ



2. $("A>B") AԪֱӽڵ
ӣƥеӼinputԪء

HTML :


  1. <div class="line number129 index128 alt2"><code class="javascript plain"><form></code></div><div class="line number130 index129 alt1"><code class="javascript plain"><label>Name:</label></code></div><div class="line number131 index130 alt2"><code class="javascript plain"><input name=</code><code class="javascript string">"name"</code> <code class="javascript plain">/></code></div><div class="line number132 index131 alt1"><code class="javascript plain"><fieldset></code></div><div class="line number133 index132 alt2"><code class="javascript spaces">      </code><code class="javascript plain"><label>Newsletter:</label></code></div><div class="line number134 index133 alt1"><code class="javascript spaces">      </code><code class="javascript plain"><input name=</code><code class="javascript string">"newsletter"</code> <code class="javascript plain">/></code></div><div class="line number135 index134 alt2"><code class="javascript plain"></fieldset></code></div><div class="line number136 index135 alt1"><code class="javascript plain"></form></code></div><div class="line number137 index136 alt2"><code class="javascript plain"><input name=</code><code class="javascript string">"none"</code> <code class="javascript plain">/> </code></div>
ƴ


jQuery :

  1. <code class="javascript plain">$(</code><code class="javascript string">"form > input"</code><code class="javascript plain">) </code>
ƴ


:

  1. <code class="javascript plain">[ <input name=</code><code class="javascript string">"name"</code> <code class="javascript plain">/> ] </code>
ƴ



3. $("A+B") AԪغֵܽڵ㣬ֱӽڵ
ӣƥи label input Ԫ

HTML :


  1. <div class="line number150 index149 alt1"><code class="javascript plain"><form></code></div><div class="line number151 index150 alt2"><code class="javascript plain"><label>Name:</label></code></div><div class="line number152 index151 alt1"><code class="javascript plain"><input name=</code><code class="javascript string">"name"</code> <code class="javascript plain">/></code></div><div class="line number153 index152 alt2"><code class="javascript plain"><fieldset></code></div><div class="line number154 index153 alt1"><code class="javascript spaces">      </code><code class="javascript plain"><label>Newsletter:</label></code></div><div class="line number155 index154 alt2"><code class="javascript spaces">      </code><code class="javascript plain"><input name=</code><code class="javascript string">"newsletter"</code> <code class="javascript plain">/></code></div><div class="line number156 index155 alt1"><code class="javascript plain"></fieldset></code></div><div class="line number157 index156 alt2"><code class="javascript plain"></form></code></div><div class="line number158 index157 alt1"><code class="javascript plain"><input name=</code><code class="javascript string">"none"</code> <code class="javascript plain">/> </code></div>
ƴ


jQuery :

  1. <code class="javascript plain">$(</code><code class="javascript string">"label + input"</code><code class="javascript plain">) </code>
ƴ


:

  1. <code class="javascript plain">[ <input name=</code><code class="javascript string">"name"</code> <code class="javascript plain">/>, <input name=</code><code class="javascript string">"newsletter"</code> <code class="javascript plain">/> ] </code>
ƴ




4. $("A~B") AԪغֵܽڵ㣬ֱӽڵ
ӣҵͬ input Ԫ

HTML :


  1. <div class="line number172 index171 alt1"><code class="javascript plain"><form></code></div><div class="line number173 index172 alt2"><code class="javascript plain"><label>Name:</label></code></div><div class="line number174 index173 alt1"><code class="javascript plain"><input name=</code><code class="javascript string">"name"</code> <code class="javascript plain">/></code></div><div class="line number175 index174 alt2"><code class="javascript plain"><fieldset></code></div><div class="line number176 index175 alt1"><code class="javascript spaces">      </code><code class="javascript plain"><label>Newsletter:</label></code></div><div class="line number177 index176 alt2"><code class="javascript spaces">      </code><code class="javascript plain"><input name=</code><code class="javascript string">"newsletter"</code> <code class="javascript plain">/></code></div><div class="line number178 index177 alt1"><code class="javascript plain"></fieldset></code></div><div class="line number179 index178 alt2"><code class="javascript plain"></form></code></div><div class="line number180 index179 alt1"><code class="javascript plain"><input name=</code><code class="javascript string">"none"</code> <code class="javascript plain">/> </code></div>
ƴ


jQuery :

  1. <code class="javascript plain">$(</code><code class="javascript string">"form ~ input"</code><code class="javascript plain">) </code>
ƴ


:

  1. <code class="javascript plain">[ <input name=</code><code class="javascript string">"none"</code> <code class="javascript plain">/> ] </code>
ƴ



Դ΢http://weibo.com/techued Դ΢Źںţweb-tech
ʹõ ٱ ظ
б

ֹ

²

̳¡ͼƬѷϴվԭתԻ,µİȨԭ
վַİȨ֪ͨǵĹԱ,Ա(Email:admin@websjy.com)ʱȡȨɾ
ܾκκʽڱ̳л񹲺͹ִ!

QQ| 42011102000510|Archiver|ֻ|Դ ( ICP14013341-1

GMT+8, 2017-11-22 04:54

Powered by Discuz! X3.2

ԴԴվ  ԴAPPӦ֮

ٻظ ض б