From: jeff on 20 Dec 2009 11:11 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 20 Dec 2009 11:25 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 20 Dec 2009 11:36 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.
|
Pages: 1 Prev: kaviya number visit now Next: jQuery Attribute Summit--Latest Coverage |