Autor Beitrag
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 13.09.05 18:49 
Moinmoin. ;)

Ich quäl' euch mal wieder mit JavaScript... :tongue:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
<script type="text/javascript">
  function displaybox (handle) {
    alert(handle.parent.id);
    }
</script>
<div id="opt_farben">
  <a href="#" onclick="displaybox(this)">
    • Farben
  </a>
</div>


Bittesehr. Wieso funktioniert das nicht?! :lol: Wieso bekomme ich per parent nicht das Objekthandle des HTML-Tags, das das Objekt des aktuellen Handles umschließt?! :gruebel:

Ich kann natürlich die ID immer per Parameter angeben, aber this ist einfach "eleganter"... :tongue:

Danke schonmal... ;)
slt, WeBBy
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 13.09.05 19:06 
Okay. Falsche Eigenschaft verwendet. Um ein Element nach außen zu gehen, nimmt man parentNode statt parent. ;)

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
<script type="text/javascript">
  function displaybox (handle) {
    alert(handle.parentNode.id);
    }
</script>
<div id="opt_farben">
  <a href="#" onclick="displaybox(this)">
    • Farben
  </a>
</div>


slt, WeBBy ;)