Hi.

I'm applying an onclick to every span of a webpage, and I'd like to test for the ID of the parent of the span that's clicked.

Here's my HTML...


Code HTML4Strict:
<ins id="Alpha">
    <span id="A Span">Click here to Alert the ID of Parent Object</span>
 
    <form action="" method="post"></form>
</ins>
 
<ins id="Beta">
    <span id="B Span">Click here to Alert the ID of Parent Object</span>
 
    <form action="" method="post"></form>
</ins>

...and the Javascript below this...

Code JavaScript:
<script type="text/javascript">
<!--
// Select all Span Objects
    var spans = document.getElementsByTagName('span');
 
// Loop through Array of Span Objects and apply Triggers
    for(var i = 0; i < spans.length; i++)
        {
        spans[i].onclick = function()
            {
            alert('Span Clicked');
            alert(this.id);
            alert(this.parent.id);
            }
        }
-->
</script>

...which makes sense to me, but somehow I'm getting the following error when a span is clicked...

this.parent is undefined
Any ideas ?

Thanks.