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

Reply via email to