Jquery set attribute for a label
Posted
by VictorS
on Stack Overflow
See other posts from Stack Overflow
or by VictorS
Published on 2010-04-07T23:14:11Z
Indexed on
2010/04/07
23:23 UTC
Read the original article
Hit count: 186
Is it possible to set "for"(AssociatedControlID) attribute using jQuery? I am trying something like this to set it to the very next control that appears after label:
$('label.asssociateClass').each(function()
{
var toAssociate = $(this).next(':input');
$(this).attr("for", toAssociate.attr("id"));
});
The problem is that if I don't set it on a server through AssociatedControlID it never gets here since it's rendered as span
instead of label
in that case. Is there a way to overcome this or I have to do it on a server?
© Stack Overflow or respective owner