forcing firefox skip "text nodes" in DOM parsing by javascript -
hi
i'm writing javascript code traverse html dom , highlight elements.
problem firefox returns whitespaces text node.
there solution force return tags? example need "firstchild" return first tag , not text!
thanks
you can check if node element node.nodetype === 1
.
you can implement new dom travelsal api functions.
var dummy = document.createelement("div"); var firstelementchild = ('firstelementchild' in dummy) ? function (el) { return el.firstelementchild; } : function (el) { el = el.firstchild; while (el && el.nodetype !== 1) el = el.nextsibling; return el; }
firstelementchild(el)
Comments
Post a Comment