jQuery if checkbox is checked to toggle classes

Posted by Lynx on Stack Overflow See other posts from Stack Overflow or by Lynx
Published on 2014-08-24T15:28:16Z Indexed on 2014/08/24 16:20 UTC
Read the original article Hit count: 284

Filed under:
|
|

I am needed to change my jQuery code up. Instead of the label toggling the class and showing the icon I need it to where if the checkbox is checked to show to toggle those classes. I have tried prop and is but I couldn't get them to work properly. The reason for the change is I want to preload data into the form and if it's going to be checked those toggles need to reflect that change.

http://jsfiddle.net/70fbLooL/2/

EDIT

Seems to be confusion as to exactly what I am trying to do. The fiddle I provided works perfectly fine. The problem is if I want to call the form from server-side and pre-populate the form the checkbox toggles will not show that they are checked because it's based on the clicked function. I need it to be based on if the checkbox equal true or checked. That way if the value equals true from the server-side call it will toggle those classes and look like it's checked.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery