[jquery position selector: First-child:last-child] Hardening Description: Select the element that belongs to the first (last) position in the collection of child elements belonging to its parent element and all sibling elements

Source: Internet
Author: User

Hardening Instructions: Select the element that belongs to the first (last) position in the collection of child elements in its parent element and all sibling elements

Note and: The difference between first:last

Instance:

<! DOCTYPE html>;} Html{font:15px/1.2em ' imitation '; color: #000;}#demo {width:850px;height:450px;margin:75px auto;} P{white-space:pre-Wrap;} . div-second{border:1px solid #921; margin:10px 0;padding:0;} Div> *{margin:5px 0; cursor:pointer;}</style><script type= ' Text/javascript ' >       $(function(){                /** Definition and usage: The First-child selector selects the first conforming element in the collection of child elements belonging to its parent element and all sibling elements tip: use: Las The T-child selector selects the last conforming element declaration in the collection of child elements belonging to its parent and all sibling elements: Use this selector to select multiple conforming elements*/        $('. Div-second p:first-child '). css ({' backgroundcolor ': ' #F33942 '),}); $('. Div-second p:last-child '). css ({' backgroundcolor ': ' #C39A6B '),}); });</script>

[jquery position selector: First-child:last-child] Hardening Description: Select the element that belongs to the first (last) position in the collection of child elements belonging to its parent element and all sibling elements

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.