1. Attribute filter selector
Selector | describe | Example |
[attribute] | select the selector with this property | $('div[id]') |
[attribute=value] | Select the element whose attribute value is value | $('div[color=red]') |
[attribute!=value] | Select elements whose attribute value is not value | $('div[color!=red]') |
[attribute^=value] | Select elements whose attribute value starts with value | $('div[titile^=text]') |
[attribute*=value] | Selects elements whose attribute value ends with value | $('div[title*=text]') |
[attribute|=value] | Selects elements whose attributes are prefixed with value | $ ('div [title | = en]') |
[attribute~=value] | Selects the element containing value in the value separated by a space | $('div[titile~=uk]') |
[attribule1][attribule2] | Select elements for composite attributes | $('div[color][name]') |
2. Child element filter selector
1.
:nth-child(even) selects the element with an even index under the parent element
:nth-child(odd) selects the element with an odd index under the parent element
:nth-child(2) selects the element with index 2 under the parent element
:nth-child(3n) selects the element whose index is a multiple of 3 under the parent element
:nth-child(3n+1) selects the element whose index is 3n+1 under the parent element
2.
:first-child selects the first child element of the parent element.
:last-child selects the last child element of the parent element.
:only-child selects the only child element of the parent element.
example
$('div.one:only-child') .css('background','red')//Select the only child element in the parent element one and change its background color
three. Form object property filter selector
Selector | describe | Example |
:enabled | select all available elements | $('#form1:enable'); Select the form available element with id 'form' |
:disable | Select unavailable elements | $('#form1:disable'); selects the form unavailable element with id 'form' |
:checked | Select all selected elements (radio boxes, checkboxes) | $('input:checked'); select the selected input element |
:selected | Select all selected option elements (drop-down box) | $('select :selected') selects all selected elements in the drop-down box |
Four: Form object attribute filtering example
Selector | describe | Example |
:input | Select all <input><texarea><select><button> elements | $(':input') |
:text | Select all single-line text boxes | $(':text') |
:password | Check all password boxes | $(':password') |
:radio | Check all radio boxes | $(':radio') |
:checkbox | Check all checkboxes | $(':checkbox') |
:submit | Check all submit buttons | $(':submit') |
:image | Select all images button | $(':image') |
:reset | Select all reset buttons | $(':reset') |
:button | select all buttons | $(':buttom') |
:file | Select all upload domains | $(':file') |
:hidden | 选取所有不可见元素 | $(':hidden') |