คู่มืออ้างอิง jQuery - โซ่เลือก

jQuery โซ่เลือก

เลือกตัวแทน ตัวอย่าง เลือก
* $("*") องค์ประกอบทั้งหมด
#id $("#lastname") id="lastname" องค์ประกอบ
.class $(".intro") องค์ประกอบที่มี class="intro"
element $("p") องค์ประกอบ <p> ทั้งหมด
.class.class $(".intro.demo") องค์ประกอบที่มี class="intro" และ class="demo"
     
:first $("p:first") องค์ประกอบ <p> แรก
:last $("p:last") องค์ประกอบ <p> สุดท้าย
:even $("tr:even") องค์ประกอบ <tr> ที่เป็นเลขใหญ่
:odd $("tr:odd") องค์ประกอบ <tr> ที่เป็นเลขเล็ก
     
:eq(index) $("ul li:eq(3)") องค์ประกอบที่สี่ในรายการ (index จาก 0 เริ่ม)
:gt(no) $("ul li:gt(3)") ระบุองค์ประกอบที่ index มากกว่า 3
:lt(no) $("ul li:lt(3)") 列出 index 小于 3 的元素
:not(selector) $("input:not(:empty)") 所有不为空的 input Ԫູນ
     
:header $(:header) 所有标题元素 <h1> - <h6>
:animated   所有动画元素
     
:contains(text) $(:contains('W3School')) 包含指定字符串的所有元素
:empty $(:empty) 无子(元素)节点的所有元素
:hidden $("p:hidden") 所有隐藏的 <p> Ԫູນ
:visible $("table:visible") 所有可见的表格
     
s1,s2,s3 $("th,td,.intro") 所有带有匹配选择的元素
     
[attribute] $("[href]") 所有带有 href 属性的元素
[attribute=value] $("[href='#']") 所有 href 属性的值等于 "#" 的元素
[attribute!=value] $("[href!='#']") 所有 href 属性的值不等于 "#" 的元素
[attribute$=value] $("[href$='.jpg']") 所有 href 属性的值包含以 ".jpg" 结尾的元素
     
:input $(:input) 所有 <input> Ԫູນ
:text $(:text) 所有 type="text" 的 <input> Ԫູນ
:password $(:password) 所有 type="password" 的 <input> Ԫູນ
:radio $(:radio) 所有 type="radio" 的 <input> Ԫູນ
:checkbox $(:checkbox) 所有 type="checkbox" 的 <input> Ԫູນ
:submit $(:submit) 所有 type="submit" 的 <input> Ԫູນ
:reset $(:reset) 所有 type="reset" 的 <input> Ԫູນ
:button $(:button) 所有 type="button" 的 <input> Ԫູນ
:image $(':image') ทั้งหมด element <input> ที่มี type="image"
:file $(':file') ทั้งหมด element <input> ที่มี type="file"
     
:enabled $(':enabled') ทั้งหมด element input ที่ถูกเปิดใช้งาน
:disabled $(':disabled') ทั้งหมด element input ที่ถูกบล็อค
:selected $(':selected') ทั้งหมด element input ที่ถูกเลือก
:checked $(':checked') ทั้งหมด element input ที่ถูกเลือก

ดู

ตูติลีวิดีโอ:การใช้งานสัญญาณเลือก jQuery สำหรับตัวเลือกอิเล็กทรอนิกส์