one, get child nodes 
 
For example, is a DIV element with the test ID, so we select, $ (' #test '), we want to find a class under this div as the span element of demo, there are several ways 
1, the use of filter conditions 
 
$ (' #test Span.demo ') 
 
2. Use the Find () function 
 
$ (' #test '). Find (' Span.demo ') 
 
3. Use the Children () function 
 
$ (' #test '). Children (' Span.demo ') 
 
 
Second, get the parent node 
jquery gets more of the parent element methods, such as parent (), parents (), closest (), which can help you find the parent element or node 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
<ul class= "Parent1" > 
  
<li><a href= "#" id= "Item1" >jquery Get parent node </a></li> 
  
<li><a href= "#" >jquery Get parent element </a></li> 
  
</ul> 
  
 
 
 
  
Our goal is to use the ID of item1 note A to the class for the Parent1 UL elements, there are several ways: 
 
1.$ (' #item1 '). Parent (). Parent ('. Parent1 '); 
 
2.$ (' li:parent '); 
 
3.$ (' #items '). Parents ('. Parent1 '); 
 
4.$ (' #items1 '). Closest ('. Parent1 '); 
 
Closest first checks whether the current element matches, and returns the element itself if it matches. If it does not match, look up the parent element, one level up, until you find the element that matches the selector. If nothing is found, an empty jquery object is returned. 
 
The main differences between closest and parents are: 1, the former from the current element to match the search, the latter from the parent element to match the search, 2, the first step up until found the matching element stopped, the latter has been looking up until the root element, and then put these elements into a temporary collection, Filtering with the given selector expression, 3, which returns 0 or 1 elements, which may contain 0, 1, or more elements. Closest is useful for handling event delegation.