Tagubilin ng jQuery - Selector

Selector ng jQuery

Pilihan ng selector 实例 Tuklasin
* $("*") Lahat ng elemento
#id $("#lastname") elemento na may id="lastname"
.class $(".intro") Lahat ng elemento na may class="intro"
elemento $("p") Lahat ng <p> elemento
.class.class $(".intro.demo") Lahat ng elemento na may class="intro" at class="demo"
     
:first $("p:first") Unang <p> elemento
:last $("p:last") Huling <p> elemento
:even $("tr:even") Lahat ng kahon na <tr> na kapitbahay
:odd $("tr:odd") Lahat ng kahon na <tr> na kapitbahay
     
:eq(index) $("ul li:eq(3)") Ikaapat na elemento sa listahan (index mula sa 0)
:gt(no) $("ul li:gt(3)") Lista ng mga elemento na may index na mas malaki sa 3
:lt(no) $("ul li:lt(3)") Ilista ng element na may index na mas mababa sa 3
:not(selector) $("input:not(:empty)") Lahat ng input element na walang laman
     
:header $(":header") Lahat ng element na may title <h1> - <h6>
:animated   Lahat ng element na may animation
     
:contains(text) $(":contains('W3School')") Lahat ng element na naglalaman ng tinukoy na string
:empty $(":empty") Lahat ng element na walang anak (element) node
:hidden $("p:hidden") Lahat ng nakahidng <p> element
:visible $("table:visible") Lahat ng nakikitang table
     
s1,s2,s3 $("th,td,.intro") Lahat ng element na may katumbas na selector
     
[attribute] $("[href]") Lahat ng element na may attribute na href
[attribute=value] $("[href='#']") Lahat ng element na may value ng attribute na href na magkapareho sa "#"
[attribute!=value] $("[href!='#']") Lahat ng element na may value ng attribute na href na hindi magkapareho sa "#"
[attribute$=value] $("[href$='.jpg']") Lahat ng element na may value ng attribute na href na nagtatapos sa ".jpg"
     
:input $(":input") Lahat ng <input> element
:text $(":text") Lahat ng <input> na may attribute na type="text"
:password $(":password") Lahat ng <input> na may attribute na type="password"
:radio $(":radio") Lahat ng <input> na may attribute na type="radio"
:checkbox $(":checkbox") Lahat ng <input> na may attribute na type="checkbox"
:submit $(":submit") Lahat ng <input> na may attribute na type="submit"
:reset $(":reset") Lahat ng <input> na may attribute na type="reset"
:button $(":button") Lahat ng <input> na may attribute na type="button"
:image $(:image) All <input> Elements with type="image"
:file $(:file) All <input> Elements with type="file"
     
:enabled $(:enabled) All Active input Elements
:disabled $(:disabled) All Disabled input Elements
:selected $(:selected) All Selected input Elements
:checked $(:checked) All Selected input Elements

See

Tutorial:jQuery Element Selector Syntax