首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >引导开关没有加载。

引导开关没有加载。
EN

Stack Overflow用户
提问于 2015-10-28 17:49:15
回答 1查看 9.3K关注 0票数 1

我已经包含了所有的依赖项,我仍然不知道为什么它没有给我我想要的开关。我漏掉了什么吗?此外,当我单击“保存更改”按钮时,无法获得post数据。

代码语言:javascript
复制
<link href="bootstrap-3.3.5-dist/css/bootstrap.css" rel="stylesheet">
<link href="bootstrap-switch/css/bootstrap3/bootstrap-switch.css" rel="stylesheet">
<script> src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="bootstrap-3.3.5-dist/js/bootstrap.js"></script>
<script src="bootstrap-switch/js/bootstrap-switch.js"></script>

代码语言:javascript
复制
<h2 class="h4">State</h2>
<div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-id-switch-modal bootstrap-switch-animate bootstrap-switch-on" style="width: 102px;">
  <div class="bootstrap-switch-container" style="width: 150px; margin-left: 0px;">
    <span class="bootstrap-switch-handle-on bootstrap-switch-primary" style="width: 50px;">ON</span>
    <span class="bootstrap-switch-label" style="width: 50px;">&nbsp;</span>
    <span class="bootstrap-switch-handle-off bootstrap-switch-default" style="width: 50px;">OFF</span>
    <input id="switch-modal" type="checkbox" checked="">
  </div>
</div>
<button type="button" class="btn btn-primary" data-switch-get="state" data-dismiss="modal">Save changes</button>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-28 18:08:17

首先,从以下位置更正jQuery脚本:

代码语言:javascript
复制
<script> src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

至:

代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

根据自举开关文档:

您只需包括您的输入:

代码语言:javascript
复制
<input id="switch-modal" type="checkbox" checked>

并在JavaScript中像这样初始化它:

代码语言:javascript
复制
$('#switch-modal').bootstrapSwitch();

CODEPEN实例

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33398117

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档