get the parents with one click on a child element [see example]
EDIT
Maybe I must ask it like this.
How is it possible to get the table width without getelmentbyID/Name
by clicking with the mouse on the text "some text for example".
HTML Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle" align="center">
<td bgcolor="#66FFFF"><b>some text for example</b></td>
</tr>
</table>
<table width="34" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle" align="center">
<td bgcolor="#66FFFF"><b>bla bla a other table</b></td>
</tr>
</table>
below the old story.
----------------------
H!
I need a script to get the parents with one click on a child element.
I have found this to get a element with one mouseclick
function dosomething(e){
e.srcElement // here is the selected element.
}
document.onmousedown = function(){dosomething(event)}
Then whe have this html code for example.
HTML Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle" align="center">
<td bgcolor="#66FFFF"><b>some text for example</b></td>
</tr>
</table>
Now I press for example "some text for example" with my mouse.
Then I want to know who the parents are and return this in a for loop for example.
function dosomething(e){
for(object in e.srcElement.getallparents){
alert(object.TagName);
alert(ojbect.width);
}
}
b -
td -
tr -
table - 100% < - in this example the most outer parent
And now the not easy part: I can't use getElementById/TagName.
Thanks very much,
GCMartijn :)