Posted By

jatkins on 04/11/11


Tagged

element html DOM childnodes


Versions (?)

Retrieve only childNodes that are HTML elements


 / Published in: JavaScript
 

Released into the public domain. Example: elementNodes(document.getElementById('content')) refers to an array of all the elements inside the element with the ID content.

  1. function elementNodes(elmnt) {
  2. nodes = [];
  3. for(var i=0;i<elmnt.childNodes.length;i++) {
  4. if(elmnt.childNodes[i].nodeType==1)
  5. nodes.push(elmnt.childNodes[i]);
  6. }
  7. return nodes;
  8. }

Report this snippet  

You need to login to post a comment.