|
Description: A couple quick functions to save you the hassle of repeating parentNode and firstChild continuously.
Syntax: getChildOf(object, integer) getParentOf(object, integer)
function getChildOf(a, b) { while(!a.data && a.firstChild && b > 0) a = a.firstChild, b --; return a; } function getParentOf(a, b) { while(a.parentNode && b > 0) a = a.parentNode, b --; return a; }
Example: <html> <body><div><span><b>hey</b></span></div></body> </html>
var d = document.body; alert(getChildOf(d, 4).data) // alert "hey"
|
|
|
|
very nice, another great piece in the library
|
I'm starting this revolution: This is my sandbox, y'all just dig'n.
|
|
|
|
These are just kinda random, but nice functions. Maybe give a brief explanation of the second parameter though. Some people might not be what it's for.
|
|
|
|
|
These are just kinda random, but nice functions. Maybe give a brief explanation of the second parameter though. Some people might not be what it's for. Eh, I wouldn't have added these if I hadn't written the fragmentElement() function along with them.
|
|
|
|
How does it handle white spaces ?
|
|
|
|
|
It just reiterates .firstChild. I'm not passing anything special through the function. It handle whitespace like the actual method would.
|
|
|