-
jQuery Traversing Siblings
Traversing Sideways in DOM Tree In logical relationships siblings are those elements that share the same parent. jQuery provides several methods such as siblings(), next(), nextAll(), nextUntil(), prev(), prevAll() and prevUntil() that you can use to traverse sideways in the DOM tree. jQuery siblings() Method The jQuery siblings() method is used to get the sibling elements of the selected element. The following example will highlight the siblings of…
-
jQuery find() Method
The jQuery find() method is used to get the descendant elements of the selected element. The find() and children() methods are similar, except that the find() method search through multiple levels down the DOM tree to the last descendant, whereas the children() method only search a single level down the DOM tree. The following example will add a border around all the <li> elements that are descendants…
-
jQuery Traversing Descendants
Traversing Down the DOM Tree In logical relationships a descendant is a child, grandchild, great-grandchild, and so on. jQuery provides the useful methods such as children() and find() that you can use to traverse down in the DOM tree either single or multiple levels to easily find or get the child or other descendants of an element in the…
-
jQuery parents() Method
The jQuery parents() method is used to get the ancestors of the selected element. The following example will add a border around all the ancestor elements of the <li> which are <ul>, <div>, <body> and the <html> elements. Example You can optionally include one or more selector as a parameter within the parents() method to filter your search for the ancestors. The following example will apply the…
-
jQuery Traversing Ancestors
Traversing Up the DOM Tree In logical relationships an ancestor is a parent, grandparent, great-grandparent, and so on. jQuery provides the useful methods such as parent(), parents() and parentsUntil() that you can use to traverse up in the DOM tree either single or multiple levels to easily get the parent or other ancestors of an element in the hierarchy. jQuery parent() Method…