enzzzzzzzz Posted December 6, 2006 Share Posted December 6, 2006 function ascendDOM(e,target) { while (e.nodeName.toLowerCase() !=target && e.nodeName.toLowerCase() !='html') e=e.parentNode; return (e.nodeNme.toLowerCase() == 'html')? null : e;}I can't really figure out what is the outcome of this function. Link to comment Share on other sites More sharing options...
Webworldx Posted December 6, 2006 Share Posted December 6, 2006 Well you choose a target node, and it goes up the DOM tree until it finds it, or it gets to the top level (html). Link to comment Share on other sites More sharing options...
enzzzzzzzz Posted December 6, 2006 Author Share Posted December 6, 2006 Well you choose a target node, and it goes up the DOM tree until it finds it, or it gets to the top level (html).thanks for your reply, but what's the use of this kind of function in the programming? Link to comment Share on other sites More sharing options...
Webworldx Posted December 7, 2006 Share Posted December 7, 2006 It's a bit abstract, but say you were at the foot of the tree in a span tag inside a table, and you wanted to color the whole row (TR) that the span was in, then you could use ascendDom( mySpan, 'TR' ) to get there. It's a bit-script really. Link to comment Share on other sites More sharing options...
enzzzzzzzz Posted December 7, 2006 Author Share Posted December 7, 2006 that means, make the target element have the same attribute as the original one, right?i think i am kind of getting it now. thanks a lot, webworldx. Link to comment Share on other sites More sharing options...
Webworldx Posted December 7, 2006 Share Posted December 7, 2006 It just says "navigate up from the current node to the target node, stop when you're there and return the target node". Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now