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:
but does not work, how can i do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
Here we’re assigning the function to the click event (same effect). We’re also toggling the classes
hasborderandhighlighted. 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.