Skip to content

Instantly share code, notes, and snippets.

@omartell
Created May 15, 2011 12:22
Show Gist options
  • Save omartell/973104 to your computer and use it in GitHub Desktop.
Save omartell/973104 to your computer and use it in GitHub Desktop.
Travel the DOM function
function travelDOMland(callback, elem){
elem = elem || document.body;
callback(elem);
if(elem.hasChildNodes()){
travelDOMland(callback, elem.firstChild);
}
if(elem.nextSibling !== null){
travelDOMland(callback, elem.nextSibling);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment