getAttribute in IE

J

jeff

I'm doing a little form field checking:

<label for="field_one">Field One</label>

I'd like to know the "for" value.

In Firefox I can do:

label_reference.getAttribute("for").

In IE (I'm testing in IE6 at the moment), I get "null", not what I was
hoping for!


How do I do this?

Jeff
 
J

jeff

jeff said:
I'm doing a little form field checking:

<label for="field_one">Field One</label>

I'd like to know the "for" value.

In Firefox I can do:

label_reference.getAttribute("for").

In IE (I'm testing in IE6 at the moment), I get "null", not what I was
hoping for!

Turns out to be: htmlFor

doing:

for (var x in label_reference)

turned up that, and it seems like a thousand others!

Jeff
 
D

David Mark

Turns out to be: htmlFor

That's the property name as - for - is a reserved word, it can't be
used as a property name. It's the same reason that the - class -
attribute value is referenced by the - className - property. IE < 8
and compatibility mode confuse attributes and properties, so it is
best to avoid getAttribute whenever possible (virtually always in
HTML). Just reference the property:-

label_reference.htmlFor
doing:

for (var x in  label_reference)

turned up that, and it seems like a thousand others!

Those are properties.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top