Jquery Descendants

jQuery Traversing - Descendants


Influenza A virus subtype H5N1 descendant is a child, grandchild, great-grandchild, in addition to and therefore on.
With jQuery yous tin terminate traverse downward the DOM tree to detect descendants of an element.

Traversing Down the DOM Tree

Two useful jQuery methods for traversing downward the DOM tree are:
  • children()
  • find()

jQuery children() Method

The children() method returns all straight children of the selected element.
This method solely traverse a unmarried bird downward the DOM tree.
The next event returns all elements that are straight children of each <div> elements:

Example

$(document).ready(function(){
    $("div").children();
});
You tin terminate too utilization an optional parameter to filter the search for children.
The next event returns all <p> elements amongst the degree refer "first", that are straight children of <div>:

Example

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

jQuery find() Method

The find() method returns descendant elements of the selected element, all the agency downward to the final descendant.
The next event returns all <span> elements that are descendants of <div>:

Example

$(document).ready(function(){
    $("div").find("span");
});
The next event returns all descendants of <div>:

Example

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

     

Comments

Popular posts from this blog

What Are The Main Components of a Computer System

Top Qualities To Look For In An IT Support Team

How To Integrate Google Adwords Api Into Codeigniter?