JQuery Find label
First, the basic label
. 1 ID Selector:
$("#id(名称)")
$("#cent")
2 tag selector:
$("tabName(便签名称)")
$("a")
. 3 class selector:
$(".class(class选择器名称)")
$(".b")
4 in conjunction with:
$("标签名称.选择器") // 找到有c1 class类的div标签
$("div.c")
5 All element selector:
$("*")
6 a combination of a selector:
$("id选择器, class选择器, 标签选择器")
Second, the level selector:
Y 1 x all descendants (children and grandchildren
$("选择器1 选择器2")
$ ( "X y"); // long as the selector 2
All the sons of 2 x y (son)
$("选择器1 > 选择器2")
$ ( "X> y"); // as long as the son
Find all 3 immediately after the y-x
$("选择器1 + 选择器2")
$ ( "X + y"); // (a)
All the brothers after 4 x y
$("选择器1 ~ 选择器2")
$ ( "X ~ y"); // (s)
Third, the basic filter
1 First
:first
2 final
:last
3 index is equal to that of the element index
:eq(index)
4 Match all even-numbered elements of an index value, starting from zero count
:even
5 Match all index value greater than a given element
:odd
6 all matching elements smaller than a given value of the index
:gt(index)
Remove all not meet the conditions of the label
:lt(index)
7 Remove all not satisfy the conditions of the label
:not(元素选择器)
Select all 8 comprises a plurality of labels or tags therein (refer to find progeny element)
:has(元素选择器)
Fourth, the attribute selector
$("tagName[attrbute]")
$("tagName[attrbute=name]")// 属性等于
[attribute!=value]// 属性不等于
$("input[type=text]")
$("input[type]")
V. Form Filter
$(":text")
$(":password")
$(":file")
$(":radio")
$(":checkbox") // 找到所有的checkbox
$(":submit")
$(":reset")
$(":button")
表单对象属性:
$(":enabled")
$(":disabled")
$(":checked")
$(":selected")
- Find input tags available
<form>
<input name="email" disabled="disabled" />
<input name="id" />
</form>
$("input:enabled") // 找到可用的input标签
- Find the selected option:
<select id="s1">
<option value="beijing">北京市</option>
<option value="shanghai">上海市</option>
<option selected value="guangzhou">广州市</option>
<option value="shenzhen">深圳市</option>
</select>
$(":selected") // 找到所有被选中的option
Sixth, the filter method
1 next element:
$("#id").next() // 下一个标签
$("#id").nextAll() // 标签下面的全部
$("#id").nextUntil("#i2") // 两者之间
2 on an element:
$("#id").prev() // 上一个标签
$("#id").prevAll() // 上一个标签全部
$("#id").prevUntil("#i2") // 两者之间
3 Father element:
$("#id").parent()
$("#id").parents() // 查找当前元素的所有的父辈元素
$("#id").parentsUntil() // 查找当前元素的所有的父辈元素,直到遇到匹配的那个元素为止。
4 sons and brothers elements:
$("#id").children();// 儿子们
$("#id").siblings();// 兄弟们
Find 5
$("div").find("p") ===>等价于$("div p")
6 Screening
Filter out elements that match the specified expression collection. This method is used to narrow down. A plurality of expressions separated by commas
$("div").filter(".c1") ===> 等价于 $("div.c1") // 从结果集中过滤出有c1样式类的
7 supplement
.first() // 获取匹配的第一个元素
.last() // 获取匹配的最后一个元素
.not() // 从匹配元素的集合中删除与指定表达式匹配的元素
.has() // 保留包含特定后代的元素,去掉那些不含有指定后代的元素。
.eq() // 索引值等于指定值的元素