JQuery (4) filter selector: attribute filter selector & amp; child element filter selector & amp; form filter selector, jquery Selector

Source: Internet
Author: User

JQuery (4) filter selector: attribute filter selector & child element filter selector & form filter selector, jquery Selector

Iv. Attribute filter Selector

The filter rule of the attribute filter selector obtains the corresponding element through the attribute of the element.


Select the following elements and change the background color to # bbffaa.
Div element with attribute title.
The property title value is equal to the div element of "test.
The property title value is not equal to the div element of "test" (if there is no property title, it will be selected ).
The div element whose attribute title value starts with "te.
The div element whose attribute title value ends with "est.
The property title value contains the div element of "es.
Select the div element with the property id, and then select the div element whose property title value contains "es" in the result.


<Html> 
5. Child element filter Selector

The nth-child () selector details are as follows:
(1): nth-child (even/odd): select an element whose index value under each parent element is an even (odd) number.
(2): nth-child (2): select an element with an index value of 2 under each parent element.
(3): nth-child (3n): You can select an element whose index value under each parent element is a multiple of 3.
(3): nth-child (3n + 1): select the element whose index value is 3n + 1 for each parent element.

Select the following elements and change the background color to # bbffaa.
Each class is the first child element under the parent element of the one div.
The first child element under the parent element of a div whose class is one
The last child element under the parent element of a div whose class is one
If the parent element of a div whose class is one has only one child element, select this child element.


<Html> 

6. form filter Selector

This selector mainly filters selected form elements.

Use the val () method of the jQuery object to change the value of the <input> element available in the form.
Use the val () method of the jQuery object to change the value of the <input> element that is unavailable in the form.
Use the length attribute of the jQuery object to obtain the number of selected multiple selection boxes.
Use the text () method of the jQuery object to obtain the content selected in the drop-down box.


<Html> 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.