Click to See Complete Forum and Search --> : get the id of the div from the span inside


thechasboi
09-27-2006, 05:53 PM
I have this function that would be much more efficient if I could get the id of the parent id of the div here is the begining arangement of the div
<div id="1000"><span onclick="someFunction(this.parent.id)" ...
I need this because the span that is directly next to this one or inside the div tags could use that id in its calling function as well instead of hard coding or more coding in the first place.

thanks for the help in advance

samanyolu
09-27-2006, 06:03 PM
<div id="1000">
<span onclick="alert(this.parentNode.id)" >Click me</span></div>

thechasboi
09-27-2006, 06:19 PM
samanyolu

Thanks that was the charm. I did not realize the "Node" needed to be attached to it. Thanks again.