动态添加引导开关(带有图标),但不起作用 [英] Adding a bootstrap-switch (with an icon) dynamically but not working

查看:47
本文介绍了动态添加引导开关(带有图标),但不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用引导开关( http://www.bootstrap-switch.org/),并且我想使用图标而不是文本进行切换;我要添加的内容是通过ajax调用和.HTML属性动态添加的;我尝试了以下HTML属性传递的代码,但未显示图标,而是显示

I am using bootstrap-switch (http://www.bootstrap-switch.org/), and I want to use icons instead of texts for switchs; What I'm addding is added dynamically by an ajax call and .HTML attribute; I have tried the following code which is passed by the HTML attribute but instead of showing the icon, it is showing

<span class='icon-remove'></span>

我的代码:

<input type='checkbox' checked id='chkAll_tab3' name='chkAll_tab3' class='switch switch-success' data-label-on=\"<span class='icon-remove'></span>\" data-label-off='Archieve' />

您知道我该如何解决吗?

Do you know how I can fix it?

如果您需要更多说明,请告诉我!

If you need more clarification, please let me know!

谢谢

推荐答案

到最新版本:

<input class="make-switch" type="checkbox" data-on-text="<i class='fa fa-unlock'></i>" data-off-text="<i class='fa fa-lock'></i>"/>

对于旧版本:

<input class="make-switch" type="checkbox" data-on-label="<i class='fa fa-unlock'></i>" data-off-label="<i class='fa fa-lock'></i>"/>

init bootstrapSwitch

init bootstrapSwitch

<script>
 $(".make-switch").bootstrapSwitch();
</script>

这篇关于动态添加引导开关(带有图标),但不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆