通过ID获取 | $('#test') |
通过类名(class名) | $('.test') |
通过标签名 | $('div') |
获取所有的标题元素 <h1> ~ <h6> | $(':header') |
获取所有的动画元素 | $(':animated') |
获取所有选中的input选择(单选框、复选框) | $(':checked') |
获取第一个 <p> 元素 | 第一个 <p> 元素 |
所有 type="text" 的 <input> 元素 | $(":text") |
所有 type="password" 的 <input> 元素 | $(":password") |
所有 type="radio" 的 <input> 元素 | $(":radio") |
所有 type="checkbox" 的 <input> 元素 | $(":checkbox") |
所有 type="submit" 的 <input> 元素 | $(":submit") |
所有 type="reset" 的 <input> 元素 | $(":reset") |
所有 type="button" 的 <input> 元素 | $(":button") |
所有 type="image" 的 <input> 元素 | $(":image") |
所有 type="file" 的 <input> 元素 | $(":file") |
所有激活的 input 元素 | $(":enabled") |
所有禁用的 input 元素 | $(":disabled") |
所有被选取的 input 元素 | $(":selected") |
所有被选中的 input 元素 | $(":checked") |
最后一个 <p> 元素 | $("p:last") |
所有偶数 <tr> 元素 | $("tr:even") |
所有奇数 <tr> 元素 | $("tr:odd") |
列表中的第四个元素(index 从 0 开始) | $("ul li:eq(3)") |
index 大于 3 -(小于3) | $("ul li:gt(3)") - (lt) |
所有不为空的 input 元素 | $("input:not(:empty)") |
无子(元素)节点的所有元素 | $(":empty") |
所有隐藏的 <p> 元素 | $("p:hidden") |
所有可见的表格 | $("table:visible") |
所有带有 href 属性的元素 | $("[href]") |
所有 href 属性的值等于 "#" 的元素 | $("[href='#']") |
所有 href 属性的值不等于 "#" 的元素 | $("[href!='#']") |
所有 href 属性的值包含以 ".jpg" 结尾的元素 | $("[href$='.jpg']") |