PDA

View Full Version : Grr... Need to reference the parent DIV



AaronW
10-23-2003, 01:26 PM
Ok, I've not exactly at guru status when it comes to Javascript, so I need some help with this seemingly simple task:

I've got this:

<div style="...">
<div>Stuff here</div>
</div>

What I need to do is have an onclick event on the nested DIV that can change the overflow properties of its "parent" DIV. I thought this.parent.style would be the way to go, but apparently not.

So how do I reference that?

PS: I don't want to use IDs, as these boxes are going to be dynamically generated.

Thanks :)

liorean
10-23-2003, 01:53 PM
elm.parentNode

AaronW
10-23-2003, 02:05 PM
Moocho gracias :)

Kor
10-23-2003, 04:07 PM
PS: I don't want to use IDs, as these boxes are going to be dynamically generated.


Hm... I don't see why an ID can prevent from dinamically generate something....

AaronW
10-23-2003, 05:36 PM
Was sort of aiming for anonymous objects if that makes any sense. Just wanted to apply the onclick event to a DIV and have it know what to do without having to give it an ID.

Meh. I'm using IDs anyways. Still using the parentNode though.