📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials jQuery in Practice DOM Traversal

DOM Traversal

5 min read
Traverse the DOM with parent(), children(), find(), next(), and closest(). These navigate relative to a selected element. closest() searches up the tree and is very useful inside event delegation handlers.

Traversal Methods

$('li').parent()         // direct parent
$('ul').children()       // direct children
$('p').siblings()        // siblings
$('li').next()           // next sibling
$('li').prev()           // previous sibling
$('div').find('p')      // search descendants
$('li').closest('ul')   // nearest ancestor