grippat Posted September 10, 2007 Share Posted September 10, 2007 I'm using Javascript in XUL (similar to HTML or any other XML) and one of the attributes for a tag is "label". Specifically I'm using this attribute on a "menu" tag. Here's what the DOM is like for the section I'm having trouble with: <menubar> <menu label="stuff"> <menupopup> <menuitem label="more stuff" onclick="alert(this.label); alert(this.parentNode.parentNode.label)"/> Now here's my problem: the second alert in the onclick always says it's undefined even though the first alert always displays the correct label ("more stuff"). Why would it give me back an undefined for the second? Link to comment Share on other sites More sharing options...
aalbetski Posted September 10, 2007 Share Posted September 10, 2007 try this to get what you wantfunction getstuff(o){while o.nodeName != "menu")( o = o.parentNode)return o.label Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.