![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Kann mir wer sagen warum das untere Script einmal DIV und dann "undefined" bringt ?! |
|
html head script type="text/javascript" function go2(x) { alert(x.parentElement.firstChild.tagName); alert(x.parentElement.lastChild.tagName); } /script /head body div div onclick="javascript:go2(this);">This is a DIV</div input type="text" / /div /body /html |
#3
| |||||
| |||||
|
|
Subject: javascirpt Problem ?! |
|
Kann mir wer sagen warum das untere Script einmal DIV und dann "undefined" bringt ?! ^^^ |
|
html head script type="text/javascript" function go2(x) { alert(x.parentElement.firstChild.tagName); alert(x.parentElement.lastChild.tagName); ^^^^^^^^^^^^^ |
|
} /script /head body div div onclick="javascript:go2(this);">This is a DIV</div |
|
input type="text" / |
#4
| |||
| |||
|
|
UnTo schrieb am 03.10.2009 21:45: Kann mir wer sagen warum das untere Script einmal DIV und dann "undefined" bringt ?! Tut es das? Im opera und Firefox gibts zweimal undefined :-) [...] alert(x.parentElement.firstChild.tagName); alert(x.parentElement.lastChild.tagName); [...] Liegt im FF daran, dass sogar parentElement undefined ist... |
|
ein parentNode liefert dir dein Div, firstChild und lastChild dann deine Zeilenumbrüche, die aber kein tagName haben. Im IE triffst du mit lastChild deinen Zeilenumbruch. |
![]() |
| Thread Tools | |
| Display Modes | |
| |