匹配B的所有button元素(button, input[type=submit], input[type=reset] or input[type=button])
B:checkbox
匹配B的所有checkbox元素( input[type=checkbox])
B:enabled
匹配B的所有可用状态元素
B:file
匹配B的所有类型为input[type=file]元素
B:header
匹配B的所有<h1>-<h6>类型元素
B:hidden
匹配B的所有隐藏元素
B:image
匹配B的所有类型为input[type=image]元素
B:input
匹配B的所有输入类型元素,包括:<input>, <select>, <textarea> and <button>
B:not(f)
匹配B的不匹配f的所有元素
B:parent
匹配B的子元素不为空的元素
B:password
匹配B的类型为input[type=password]的元素
B:radio
匹配B的类型为input[type=radio]的元素
B:reset
匹配B的类型为input[type=reset]或 button[type=reset]的元素
B:submit
匹配B的所有类型input[type=submit] or button[type=submit]的元素
B:selected
匹配B的状态为选中状态的元素,仅<option>拥有此状态
B:text
匹配B的所有类型为input[type=text]的元素
B:visible
匹配B的所有状态可见的元素
示例:
语句
说明
$(“img:animated”)
selects all <img> elements that are undergoing animation
$(“:button:hidden”)
selects all button type elements that are hidden
$(“input[name=myRadioGroup]:radio:checked”)
selects all radio elements with the name attribute value of myRadioGroup that are checked
$(“:text:disabled”)
selects all text fields that are disabled
$(“#xyz p :header”)
selects all header type elements within <p> elements that are within an element with an id value of xyz. Note the space before :header that prevents it from binding directly to the p.
$(“option:not(:selected)”)
selects all unselected <option> elements
$(“#myForm button:not(.someClass)”)
selects all buttons from the <form> with the id of myForm that do not possess the class name someClass.
$(“select[name=choices] :selected”)
selects the selected <option> elements within the <select> element named choices.
$(“p:contains(coffee)”)
selects all <p> elements that contain the text coffee