On May 20, 8:35 pm, Sourabh <sourabhmkulka...@gmail.com> wrote: > Hi > > I am new to jQuery.I have a problem where I want to traverse through > DOM.For example a complete webpage.Is there any jQuery way to traverse > complete DOM of the current page where the jQuery script resides ?
Traversing the DOM is trivial, using recursion it requires perhaps 4 lines of plain javascript. What do you actually want to do? <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <title>domWalk</title> <script type="text/javascript"> function domWalk(node) { node = node || document.getElementsByTagName('html')[0]; // do something with node console.log(node.nodeName + ':' + node.nodeType); if (node.childNodes) { for (var i=0, len=node.childNodes.length; i<len; i++) { domWalk(node.childNodes[i]); } } } window.onload = function(){domWalk()}; </script> <div><p></div> -- Rob