That should work for your markup $(document).ready(function(){ $("input[type=radio]:checked + label").addClass("hilite"); $("input[type=radio]").change(function () { $(this).parent().find("label.hilite").removeClass("hilite"); var id = $(this).attr("id"); $("label[for="+ id + "]").addClass("hilite"); }); });
On Thu, Mar 12, 2009 at 10:50, mdjamal <mail4ja...@gmail.com> wrote: > > Hi, > > Thanks it worked like charm, but when I have a series of radio in > groups, the class is applied to only one radio from the two sets, in > below example there are two forms with radios, I am trying to have > checked one with hilite class in both the forms, hope I am explaining > myself well cause I sound like confused ;-) > > <form action="" method="get"> > <input name="" type="radio" value="" id="yes" checked="checked" / > ><label for="yes">check me</label> > <input name="" type="radio" value="" id="no" /><label for="no">checkme > not</label> > </form> > > <form action="" method="get"> > <input name="" type="radio" value="" id="yes1" checked="checked" / > ><label for="yes1">check me</label> > <input name="" type="radio" value="" id="no1" /><label > for="no1">checkme not</label> > </form> > > Thanks again!