I have this code:
and
$(\"label\").click(function () {
$(
Clicking the label also triggers a click on the input so bind the change event to the checkbox itself:
$(function(){
$("label input").on("click",function(){
$(this).parent().toggleClass("active");
});
});
.active {color:red;}
If you don't need to support old browsers, you could use the :checked
pseudo-class in CSS instead:
input[type=checkbox]:checked + label {color:red;}