jquery accumulates ~children (": eq ()") with Children (). EQ ()

Source: Internet
Author: User

Today I saw the original written code ~ suddenly thought of children (": EQ (2)") and Children (). EQ (2) is not the same ~ to combine their own hands ~ found it is the same, feel good rubbish by the way down. Accumulate a bit

The HTML structure is as follows

<div class= "Div" ><ul><li><span>hello</span>1</li><li><span> Hello</span>2</li><li><span>hello</span>3</li><li><span>hello </span>4</li><li><span>hello</span>5</li></ul><ul><li> <span>hello</span>11</li><li><span>hello</span>22</li><li>< Span>hello</span>33</li><li><span>hello</span>44</li><li><span >hello</span>55</li></ul><ul><li><span>hello</span>111</li> <li><span>hello</span>222</li><li><span>hello</span>333</li> <li><span>hello</span>444</li><li><span>hello</span>555</li> </ul><ul><li><span>hello</span>1111</li><li><span>hello</ Span>2222</li> <li><span>hello</span>3333</li><li><span>hello</span>4444</li ><li><span>hello</span>5555</li></ul></div>

Then introduce jquery to compare the difference between the two (there is no difference in the actual, that is, the writing method is not the same)

The code is as follows

$ (' ul '). Children (": EQ (1)"). CSS (' Color ', ' red '); $ (' ul '). Children (). EQ (2). CSS (' Color ', ' red ');

  

It's no different than changing to something else.

There is the difference between children () and find ()-the test found that the parentheses of find () must be written in-otherwise invalid

$ (' div '). Find (). EQ (2). CSS (' Color ', ' red ');

  

The following is a valid

$ (' div '). Find (' ul '). EQ (2). CSS (' Color ', ' red ');

The summary is: find () looks for descendants, descendants, children, and parameters must be filled

Children () itself is looking for the descendants, the parameters in the optional fill

jquery accumulates ~children (": eq ()") with Children (). EQ ()

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.