JQ 选择器
- $("*") 选择所有的元素
- $(“#id ”) #符号后面加ID名称,ID选择器
- $(“.class”) .符号后面加类名,类选择器
- $("p") 标签选择器
- $(". class. class ") 多重选择器
- :first 例:$("p:first") 选择第一个 p 标签
- :last 例:$("p: last") 选择最后一个 p标签
- :even 例 $(“p:even”) 选择偶数 p标签
- :odd 例 $(“p:odd”) 选择奇数 p标签
- :eq(index) 例 $(“p:eq(index)”) 列表中的第index个元素(index 从 0 开始)
- :gt(index) 例 $(“p:gt(index)”) 列出 index 大于 3 的元素
- :lt(index) 例 $(“p:lt(index)”) 列出 index 小于 3 的元素
- :not(选择器) 例 $(“p: not (:empty)”) 所有不为空的 input 元素
- :header 例 $(":header") 所有标题元素 <h1> - <h6>
- :animated 所有动画元素
- :contains 例 $(":contains('W3School')") 包含指定字符串的所有元素
- :empty 例 $(":empty") 无子(元素)节点的所有元素
- :hidden 例 $("p:hidden") 所有隐藏的 <p> 元素
- :visible 例 $("table:visible") 所有可见的表格
- 例 $("[href]") 所有带有 href 属性的元素
- 例 $("[href='#']") 所有 href 属性的值等于 "#" 的元素
- 例 $("[href!='#']") 所有 href 属性的值不等于 "#" 的元素
- 例 $("[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") 所有 type="image" 的 <input> 元素
- :file 例 $(":file") 所有 type="file" 的 <input> 元素
- :enabled 例 $(":enabled") 所有激活的 input 元素
- :disabled 例 $(":disabled") 所有禁用的 input 元素
- :selected 例 $(":selected") 所有被选取的 input 元素
- :checked 例 $(":checked") 所有被选取的 input 元素