jquery traversal element's descendant and sibling implementation method _jquery

Source: Internet
Author: User

1. Traversing descendants

Children ()

The Children () method returns all the immediate child elements of the selected element.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Find ()

The Find () method returns the descendant elements of the selected element, all the way down to the last descendant.

Find () must add selecter if you do not add it will not show

So inside you have to add selectors such as find ("*") Find ("span")

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

2. Traverse the compatriots

Siblings ()

The siblings () method returns all sibling elements of the selected element.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Next ()

Next () A sibling element of the selected element

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Nextall ()

The Nextall () method returns all the following sibling elements of the selected element.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Nextuntil ()

The Nextuntil () method returns all the following sibling elements between two given parameters.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Prev ()

Prev ()
Prevall ()
Prevuntil ()
Prev=previous= Front.

So the traversal is the same as the previous sibling of the specified element, and next () does not give an example.

3. Filtration

A ()

The first () method returns the initial element of the selected element.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Last ()

The last () method returns the final element of the selected element.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

EQ ()

The EQ () method returns the element with the specified index number in the selected element.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Filter ()

The filter () method allows you to specify a standard. Elements that do not match this standard are removed from the collection and the matching elements are returned.

<script type= "Text/javascript" >
$ (function () {
	$ ("#btn"). Click (function () {
			$ ("div p"). Filter ("# P2 "). each (function (I, e) {
    $ (' #info '). HTML ($ (" #info "). HTML () +" ("+$ (This). attr (" id ") +") ");
</script>

Not ()

The Not () method returns all elements that do not match the criteria.

The Not () method is the opposite of filter ().

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  

Above this jquery traversal element's descendant and the sibling realization method is the small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community a lot.

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.