Explain jQuery Traversing - Descendants?

Answer

A descendant is a child, grandchild, great-grandchild, and so on.With jQuery you can traverse down the DOM tree to find descendants of an element.

 

Traversing Down the DOM Tree

Two useful jQuery methods for traversing down the DOM tree are:

  • children()
  • find()

jQuery children() Method

The children() method returns all direct children of the selected element.

This method only traverse a single level down the DOM tree.

 

Example

$(document).ready(function(){
    $("div").children();
});
 

jQuery find() Method

 

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

Example

$(document).ready(function(){
    $("div").find("span");
});

All JQUERY Questions

Ask your interview questions on jquery

Write Your comment or Questions if you want the answers on jquery from jquery Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---