25

I am using http://bootstrapswitch.site/ for toggle switch buttons. How can I get the toggle switch like 'on' or 'off' using jQuery?

My Code is :

<div class="make-switch  switch-small"><input type="radio" class="nsfw"></div>

Please tell me how to solve this issue.

GoldDragonTSU
  • 487
  • 1
  • 9
  • 23
lalith458
  • 695
  • 2
  • 12
  • 30

4 Answers4

66
$('#switcher').bootstrapSwitch('state'); // true || false
$('#switcher').bootstrapSwitch('toggleState');

Refer this link for more functions

Adeel Ansari
  • 39,541
  • 12
  • 93
  • 133
janhartmann
  • 14,713
  • 15
  • 82
  • 138
17

As far as I can tell the method has been updated (but not well documented).

$('#switcher').bootstrapSwitch('state', true)
$('#switcher').bootstrapSwitch('state', false)
bplittle
  • 355
  • 2
  • 9
3

About changing state in my case,

('#switcher').bootstrapSwitch('state', false); 

It's correct code.

Hajime
  • 139
  • 4
1
$('#switcher').bootstrapSwitch('state');

Not work for me, but in my version:

$("#switcher").bootstrapSwitch("status");

can work well.

Siro
  • 76
  • 5