Differences between jquery next nextAll nextUntil siblings

Source: Internet
Author: User

Next: an element next to $ ('')

NextAll: all peer elements after $ ('')

NextUntil: until available... So it represents all peer elements after $ (''), but it does not include the matching element before the nextUntil parameter.

Sibings: all peer elements before and after $ ('')

Simply put, next is to find his younger brother/sister, nextAll is to find all his younger brother/sister, nextUntil is to find younger brother/sister than him, siblings is to find all his brothers/sisters and all his younger siblings. So the same peer relationship, prev, prevAll, prevUntil

The following is a simple test code.
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "en">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> Document </title>
<Script type = 'text/javascript 'src = 'HTTP: // code.jquery.com/jquery-1.9.1.min.js'> </script>
</Head>
<Body>
<Div class = "first">
<A href = "#"> hhh </a>
<H1> This is a title <P> This is a test </p>
<P> This is a test </p>
<P> This is a test </p>
<P> This is a test </p>
<Div> hhha </div>
<P> This is a test </p>
<P> This is a test </p>
</Div>
<Script>
$ (Function (){
// $ ('P: first'hangzhou.next().css ('background', 'red ');
// $ ('P: first'hangzhou.nextall().css ('background', 'yellow ');
// $ ('P: first'0000.nextuntil('div'0000.css ({'font-size': 20, background: 'red '});
// $ ('P: first'hangzhou.siblings().css ('background', 'yellow ');
});
</Script>
</Body>
</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.