我买了一个基于 bootstrap/html 的管理面板,它有很多很棒的功能,其中之一是翻转开关,它看起来非常时尚,我希望将它用于我的任何产品状态。
实际代码是这样的
<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">
关机是这样的
<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>
并且switched不能正常工作,平滑停止滑动。
谢谢大家的帮助
========= 似乎管理面板的开发人员将此模块用于开关
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>
关于php - 如何使用 php 使这个翻转开关基于 mysql 的值工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30707908/