Thanks everyone.

Yes, I know the "for" attribute is reserved for labels.

Reason I ask is that I'm using Validator and was trying to target a
span for a group of check boxes where at least one needed to be
selected to validate the form.

I'll probably switch back to a label (which semantically makes sense
as well).

Much appreciated!

JP

On Mar 31, 6:55 pm, Ricardo <ricardob...@gmail.com> wrote:
> Even being invalid this is unexpected. Sizzle maps "for" to "htmlFor",
> because in labels the for value is held in the htmlFor property (for
> being a reserved word). If you had <span htmlFor="tea"></span> you
> could get it with $('span[for=tea]') in example. In your case you have
> to resort to
>
> $('span').filter(function(){
>      return this.attributes['for'].nodeValue == 'lid';
>
> });
>
> You're making two risky things at once: using an invalid attribute,
> and giving the attribute name a reserved word in javascript. That's
> asking for trouble!
>
> cheers,
> - ricardo
>
> On Mar 31, 8:13 pm, RobG <rg...@iinet.net.au> wrote:
>
>
>
> > On Apr 1, 4:44 am, Captain Betty <mcwilliams...@gmail.com> wrote:
>
> > > Hi everyone.
>
> > > I have a weird issue with selecting spans with the “for” attribute.
> > > jQuery doesn’t seem to want to select it if the span is physically on
> > > the page.
> > [...]
> > > Is this a bug? What am I doing wrong in trying to select a span on the
> > > page with a “for” attrib?
>
> > The for attribute is not valid for span elements, it is only valid for
> > label elements.  Use class.
>
> > --
> > Rob- Hide quoted text -
>
> - Show quoted text -

Reply via email to