本文爲 H5EDU 機構官方 HTML5培訓 教程,主要介紹:JavaScript強化教程 —— jQuery選擇器
html
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> 元素 :p_w_picpath $(":p_w_picpath") 全部 type="p_w_picpath" 的 <input> 元素 :file $(":file") 全部 type="file" 的 <input> 元素 :enabled $(":enabled") 全部激活的 input 元素 :disabled $(":disabled") 全部禁用的 input 元素 :selected $(":selected") 全部被選取的 input 元素 :checked $(":checked") 全部被選中的 input 元素
點擊進入JS強化教程
ide