Jump to content

Why doesn't nodeName return the node name?


Fog Juice

Recommended Posts

Why doesn't document.getElementById('node').nodeName return the name of the element? It just returns INPUT in firefox. So if you have <input name="name of input" id="node" /> and you called that, it would return INPUT instead of "name of input". Anyone have any suggestions to get an elements name from firefox?

Link to comment
Share on other sites

nodeName is deceiving, as it doesn't actually return the name attribute, rather it returns various details depending on what you are attaching it to. Here is a list:

 

http://www.devguru.com/technologies/xml_dom/16036.asp

 

Try this - It should work in firefox, but I'm dont think it will work in IE, so you will have to set up a conditional statement with separate code in IE. But try it out in IE first, as I may be wrong.

 

document.getElementById('node').getAttribute("name")

 

This should return the nodeName.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.