[jQuery] Re: Toggle class when radio checked

2009-03-13 Thread mdjamal
Hi, Thanks it works, I have the code as below, since more than one checkbox can be selected at once I've used the click function, and also changed the radio to click function as well. This way I can get it work the way I intent to, like two option either one public or private, so for ex when sel

[jQuery] Re: Toggle class when radio checked

2009-03-12 Thread Leonardo K
So, if u want hide when the radio change add this to your input radio change event. if ( $(this).val() == "public" ) $(this).parent().find("div.tags").hide(); else $(this).parent().find("div.tags").show(); The behavior for checkbox is the same as the radio button. So, applied change event

[jQuery] Re: Toggle class when radio checked

2009-03-12 Thread mdjamal
Hi, Thanks, you seem to be a jQuery guru, the solution works. I've applied it to work on checkbox now ;-) and now trying to have a set of checkbox display when one of the radio button is selected and hide them when another is selected. So like from below example, I select if its public or privat

[jQuery] Re: Toggle class when radio checked

2009-03-12 Thread Leonardo K
*This 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("hilit

[jQuery] Re: Toggle class when radio checked

2009-03-12 Thread Leonardo K
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

[jQuery] Re: Toggle class when radio checked

2009-03-12 Thread mdjamal
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 s

[jQuery] Re: Toggle class when radio checked

2009-03-12 Thread Leonardo K
Try this $(document).ready(function(){ $("input:checked + label").addClass("hilite"); $("input").change(function () { $("label.hilite").removeClass("hilite"); var id = $(this).attr("id"); $("label[for="+ id + "]").addClass("hilite"); }); }); On Thu, Mar 12, 2009 at 00:22, mdjamal wrote: >