View Full Version : accessing parentNode
01-16-2004, 06:54 PM
I am trying to change the class of the td when clicking on "test", but got an "undefined" error. What's the correct syntax to reference the parentNode or the node above the current one? thanks.
01-16-2004, 06:59 PM
I don't have a good explanation why, but I think this will work:
<a href="#" onclick="this.parentNode.className='c2'">test</a>
01-16-2004, 07:06 PM
This is a pretty simple problem, really. The browser executes the comment in the context of the page it is trying to go to - and the link does not exist on the target page, which is why it becomes undefined. If you ended the address with a void(0) instead, you'd return nothing and therefore not try to go anywhere - the context will now be the current page.
01-16-2004, 07:14 PM
thank you both! it worked!
01-16-2004, 07:30 PM
Originally posted by liorean
01-16-2004, 07:35 PM
01-17-2004, 03:03 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.