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.

Physical test (fails):

I have  <span for=”lid”>Some text here</span> in on the page.

My jQuery:

$(“span[for=lid]”).css(“background”, “red”);

Nothing happens.

(silly test)
If I give the span an attribute such as <span monkey=”tree”>Some text
here</span> and adjust the select accordingly… It’ll work.

Dynamic test (works):

I generate the span dynamically via jQuery such as:

var $checkboxAlert = $("<span/>").attr("for", "lid").text("Please
choose at least one option below");
$("input:checkbox:first").before($checkboxAlert);

I can successfully target the span and do whatever to it.

Is this a bug? What am I doing wrong in trying to select a span on the
page with a “for” attrib?

Reply via email to