var el = document.getElementById('div1').firstChild; while (el !== null) { console.log(el.nodeName); el = el.nextSibling; }
Principle: Use the Node.prototype.nextSibling return null sibling nodes at the time of acquisition is less than the back of this feature.