我买了一个基于bootstrap/html的管理面板,它有很多很棒的功能,其中一个是flip switch,看起来非常光滑,我希望用它来管理我的任何产品。
实际代码是这样的
<div data-off-label="Disabled" data-on-label="Enabled" class="switch" style="margin-top:12px;">
<input type="checkbox" checked="checked">
</div>
当我从浏览中检查元素时,我得到以下内容:
<div data-off-label="Disabled" data-on-label="Enabled" class="switch" style="margin-top:12px;">
<div class="switch-on switch-animate" style="">
<input type="checkbox" checked="checked">
<span class="switch-left">Enabled</span><label>
</label><span class="switch-right">Disabled</span>
</div>
我使用了常用的data-role="flipswitch"但是这个看起来不一样
开关看起来像这样
<div class="switch-on switch-animate">
Switch off如下图
<div class="switch-off switch animate">
请帮助我如何使用上面的改变,当页面加载取决于来自数据库的值。
我已经试过了,但是没有成功
<div data-off-label="Disabled" data-on-label="Enabled" class="switch" style="margin-top:12px;">
<div class="<?if($Status = 1){ echo 'switch-on'; } else { echo 'switch-off'; } switch-animate" style="">
<input type="checkbox" checked="checked">
<span class="switch-left">Enabled</span><label>
</label><span class="switch-right">Disabled</span>
</div>
开关不能正常工作,停止滑动。
似乎管理面板的开发人员使用这个模块的开关
http://www.bootstrap switch.org/documentation - 2. - html
您提供的文档显示,可以将复选框状态设置为父div的数据属性。
<div data-state="<?php echo ($status == 1) ? 'true' : 'false' ?>" data-off-label="Disabled" data-on-label="Enabled" class="switch" style="margin-top:12px;">
<input type="checkbox" checked="checked">
</div>