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