简体   繁体   English

引导开关不起作用

[英]Bootstrap switch doesn´t works

I am starting with Bootstrap switch.我从 Bootstrap 开关开始。

I have used the demos from http://www.jque.re/plugins/version3/bootstrap.switch/我使用了来自http://www.jque.re/plugins/version3/bootstrap.switch/的演示

The problem is that the switch doesn´t shows.问题是开关不显示。 It shows only a standard checkbox.它仅显示一个标准复选框。

<div class="make-switch" data-on="primary" data-off="info">
        <input type="checkbox" checked>
</div>

I also have included the css and js staff.我还包括了 css 和 js 人员。

JSFiddle: http://jsfiddle.net/crtLwdg4/ JSFiddle: http : //jsfiddle.net/crtLwdg4/

What am I missing here?我在这里缺少什么?

I just added this to the fiddle and it seems the appearance has changed.我刚刚将它添加到小提琴中,外观似乎发生了变化。

$(function() {
    $('.make-switch').bootstrapSwitch();
});

It seems you need to initialize the switch manually.看来您需要手动初始化交换机。 I have only taken a glance at the docs but this actually changed the appearance of the checkbox.我只看了一眼文档,但这实际上改变了复选框的外观。

UPDATE更新

I was able to get it working by adding a name property to the input and changing the jquery accordingly.我能够通过向输入添加 name 属性并相应地更改 jquery 来使其工作。 see this updated fiddle .看到这个更新的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM