Skip to main content Accessibility Feedback

Traversing the DOM


While querySelector() and querySelectorAll() search through all levels within a nested DOM/HTML structure, you may want to just get immediate descendant elements of a particular element. Use the .children property for this.

var elem = document.querySelector('#some-elem');
var descendants = wrapper.children;

Works in all modern browsers, and IE9+. You can extend support back further with polyfills.