我已经包含了所有的依赖项,我仍然不知道为什么它没有给我我想要的开关。我漏掉了什么吗?此外,当我单击“保存更改”按钮时,无法获得post数据。
<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>
<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;"> </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>
发布于 2015-10-28 18:08:17
首先,从以下位置更正jQuery脚本:
<script> src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>至:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>根据自举开关文档:
您只需包括您的输入:
<input id="switch-modal" type="checkbox" checked>并在JavaScript中像这样初始化它:
$('#switch-modal').bootstrapSwitch();CODEPEN实例
https://stackoverflow.com/questions/33398117
复制相似问题