Change CssClass JQuery ASP:Checkbox

flynny
flynny used Ask the Experts™
on
Hi all.

I have an ASP:Checkbox which I want to change the color of the text on it.

Now $('#<%=TermsCheckbox.ClientID%>').addClass('myclass');

is adding the class but the checkbox renders the text in a label using the same ID?

Any ideas how i can change this please?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
J NUnicorn wrangler

Commented:
$("input[type='checkbox']").change(function(){
    if($(this).is(":checked")){
        $(this).parent().addClass("COLOR");
    }else{
        $(this).parent().removeClass("COLOR");  
    }
});

CSS
.COLOR{

}

Author

Commented:
but i need to do it for a particular check box not all.
Unicorn wrangler
Commented:
$("#id").click(function() {
    if (this.checked){
       $(this).closest('p').addClass('COLOR');
    } else {
       $(this).closest('p').removeClass('COLOR');
    }
});
J NUnicorn wrangler

Commented:
thanks for the points

good luck on your adventures

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial