Getting all nodes inside a tag
I have a code like this: <div id="container"> Lorem ipsum dolor sit amet <p>This is a paragraph</p> <br /> <span>This is a span</span> Lorem ipsum dolor sit amet </div> Is it possible to get all text nodes and tags inside this div? I want to access each node (including texts) via an array. for example: for(var i=0;i<nodesArray.length;i++) { document.write("Node: "+nodesArray[i]+"<br />"); } OUTPUT: Node: Lorem ipsum dolor sit amet Node: This is a paragraph Node: This is a span Node: Lorem ipsum dolor sit amet I tried "all selector" in jquery but it gets only tags, not texts.. You can use the