How to find a child element

We often need to find a particular element that is contained within our selected item. This is accomplished with the .children() method. This method returns an array of all the immediate children for an item. The results can be filtered by passing a selector to the method. So, imagine we had the ID for a table row, and we wanted to see the value of the table cell that had the class of "total".

$("#theRow").children("td.total");

If needing to find a child of a child, you'll need to call children multiple times, or use the .find() method.

$("#theRow").children("td").children("div.total");
OR
$("#theRow").find("td > div.total");

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

TMW2jDRc

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.