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;     } 

usage

firstelementchild(el) 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -