Q:

Change class of Label on selected checkbox

I have several checboxes in my html, are generate dynamically so i can predict the name or the id.
The goal is when I selected a specific checkbox his label change the class i trying with this code:
http://jsfiddle.net/HHbkd/
but does not work, how can i do it?

A:

You had to add brackets to your if statement, for one. But there is an easier way to do what you wanted. Here is an example:
$(".testCheckBox").click(function() {
    $(this).parent().toggleClass("hasborder highlighted");
});

Here we're assigning the function to the click event (same effect). We're also toggling the classes hasborder and highlighted. So if hasborder exists, it will be removed. If it doesn't exist, it will be added. Same with the other.
This is just so you can visually confirm that it works.

