Search code examples
twitter-bootstrap-3bootstrap-switch

Bootstrap Switch Change Class to State


How can I change some bootstrap switch CSS classes dynamically if the state changes to true or false? In fact, if it is possible, appending a new class also may solve my problem. Is there any simple and useful way to do it? I tampered with documentation but found nothing.

The onSwitchChange event is well enough for this situation but I need some help with it.

Update

I attached an image that tells what I want to achieve.

enter image description here


Solution

  • I think CSS is the right way to go with what you are trying to achieve, all you need to do is enclose your switch inside a parent div and then write some CSS

    .parent-div .boostrap-switch-on{
      //enter styles for the ON state
      }
    .parent-div .boostrap-switch-off{
      //enter styles for the OFF state
      }