How to get twitter bootstrap toggle switch values

2020-05-17 04:37发布

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.

3条回答
劳资没心,怎么记你
2楼-- · 2020-05-17 05:18
$('#switcher').bootstrapSwitch('state'); // true || false
$('#switcher').bootstrapSwitch('toggleState');

Refer this link for more functions

查看更多
疯言疯语
3楼-- · 2020-05-17 05:20

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

$('#switcher').bootstrapSwitch('state', true)
$('#switcher').bootstrapSwitch('state', false)
查看更多
手持菜刀,她持情操
4楼-- · 2020-05-17 05:33

About changing state in my case,

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

It's correct code.

查看更多
登录 后发表回答