1. Find child element mode 1:>
For example: var anods = $ ("ul > a"); Find all a labels under UL
2. Find child element Mode 2:children ()
3. Find child element Mode 3:find ()
Here is a brief introduction to the similarities and differences between the following children () and find ():
The 1> children and find methods are used to obtain the sub-elements of element, neither of which will return text node, just like most jquery methods.
The 2> children method obtains only the child element of a subordinate element, namely: immediate children.
The 3> Find method obtains all subordinate elements, namely: descendants of these elements in the DOM tree
The parameter selector of the 4> children method is optional (optionally), which is used to filter the child elements,
But the parameter selector method of the Find method is required.
The 5> Find method can actually be implemented by using JQuery (selector, context). That is $ (' li.item-ii '). Find (' Li ') is equivalent to $ (' Li ', ' Li.item-ii ').
Cases:
<ulclass= "Level-1"> <Liclass= "Item-i">I</Li> <Liclass= "Item-ii">II<ulclass= "Level-2"> <Liclass= "Item-a">A</Li> <Liclass= "Item-b">B<ulclass= "Level-3"> <Liclass= "Item-1">1</Li> <Liclass= "Item-2">2</Li> <Liclass= "Item-3">3</Li> </ul> </Li> <Liclass= "Item-c">C</Li> </ul> </Li> <Liclass= "ITEM-III">Iii</Li></ul>
Use:
The effect is:
Use $ (' Ul.level-2 '). Find (' Li '). CSS (' border ', ' 1px solid green '); The effect is:
jquery-Get child element Children,find