javascript - 如何使用 Bootstrap Toggle 插件创建切换按钮?

标签 javascript jquery html css twitter-bootstrap

我有以下代码来创建一个切换按钮

<input type="checkbox" checked data-toggle="toggle">

我正在使用来自 http://www.bootstraptoggle.com/#usage 的这些库,

<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>

但它只是显示为一个普通的复选框。如何让它看起来很花哨?

这是我目前所获得的链接 - http://jsbin.com/bocawucili/edit?html,output

最佳答案

它归结为你的标签的顺序,jQuery 总是需要在任何需要它之前。

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
   <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
    <script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

关于javascript - 如何使用 Bootstrap Toggle 插件创建切换按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36340044/

相关文章:

javascript - 事件导航按钮中的不同颜色

javascript - 禁用超时按钮

javascript - .load() 使所有ajax加载的div刷新

html - 将鼠标悬停在 div 上不影响 div

php - 有没有办法用 div id 传递 php 变量?

javascript - 为属性设置多个值

javascript - 如何使用 jQuery 定位 img 元素的 src 属性?

javascript - 在 WordPress 用户数据库中存储 Javascript 对象

jQuery 进行动态 ajax 调用并等待它们完成

javascript - 我在 javascript 中有一个变量没有被设置为正确的值