A method of reciprocal process in jquery

Source: Internet
Author: User

The method of reciprocal inverse process in jquery reverse

In jquery, there are many ways of reciprocal processes, such as parent () and children (), parents () and find (), first () and last (), and so on, which together help to Understand.

One children () and parent ()

This is a pair of jquery methods that traverse the dom, both of which look for the upper or lower level of the element, accepting the selector parameter. Does not continue to look up or down. eg

Html:

<Div>grandfather<Div>Parent<DivID= ' self '> self<Div>Children<Div>Descendants</Div>          </Div>        </Div>      </Div></Div>

$ (' #self '). children ("div")//will only be selected to children will not be selected to descendants element $ (' #self '). parent ("div")//will only select the parent, Do not select the grandfather element
Two find () and parents ()

Find () accepts the selector or element parameter, Parents () accepts the filter parameter

In contrast to the above two methods, find () and parents () will always find the DOM text node and the top level element, as well as the above structure as an example

$ (' #self '). children ("div")//will be selected to descendants element
$ (' #self '). parent ("div")//select to grandfather Element
Three add () and not ()

Add () adds elements to the list of jquery selections, minus () subtracts elements

A method of reciprocal process in jquery

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.