From: jeff on
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
From: jeff on
jeff wrote:
> 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
>
>
> How do I do this?
>
> Jeff
From: David Mark on
On Dec 20, 11:25 am, jeff <jeff_th...(a)att.net> wrote:
> jeff wrote:
> >  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

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.