Created
March 14, 2013 09:41
-
-
Save MoOx/5160070 to your computer and use it in GitHub Desktop.
get real child nodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRealFirstChild(el){ | |
var firstChild = el.firstChild; | |
// skip TextNodes | |
while(firstChild !== null && firstChild.nodeType === 3) { | |
firstChild = firstChild.nextSibling; | |
} | |
return firstChild; | |
} | |
function getRealChilds(el){ | |
var child = el.firstChild; | |
var childs = []; | |
// skip TextNodes | |
while(child.nextSibling) { | |
child = child.nextSibling; | |
if (child.nextSibling.nodeType === 3) { | |
childs.push(child); | |
} | |
} | |
return childs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment