I'm trying to access the next sibling of a <li> which happens to be another <li> The code looks like this:
And the Javascript:
Basically, when an LI in the tutorialDiv is clicked, I want to access the next sibling (which is another LI, with more information about the LI clicked on) and toggle the visibility (using scriptaculous, but that's not my problem). In IE 7, I get the alert above just fine, alerting "RANDOMID" after clicking the first LI, but in FireFox, I get an error: "this.nextSibli lng.getAttribut e is not a function" . Any idea why it would work in IE but not firefox?
Thanks in advance
Greg
Code:
<div id='tutorials'>[INDENT]<ul>[INDENT]<li>Some List</li> <li class='Desc' id='RANDOMID'>Some Content</li> <li>Intro to AJAX</li> <li>Real World CSS</li>[/INDENT] </ul>[/INDENT] </div>
Code:
var tutorialDiv=document.getElementById("tutorials"); var tutorialLI=tutorialDiv.getElementsByTagName("li"); for(var i=0; i<tutorialLI.length; i++){ tutorialLI[i].onclick=function(){ alert(this.nextSibling.getAttribute("id")); } }
Thanks in advance
Greg
Comment