[英]Alternative to jQuery mobile / Switch + Toggle btn
I wish to not USE jQuery mobile; 我不希望使用jQuery mobile; I kinda can't stand it. 我有点受不了。
But I need to create aa mobile friendly; 但是我需要创建一个移动友好的网站。 mobile first, simple Switch toggle button. 移动优先,简单的“切换”切换按钮。
Nothing fancy just like the above; 没有什么比上面更花哨的了; I'd likely go in and just add my green. 我可能会进去并添加我的绿色。
Any good alternatives for mobile? 手机有什么好的选择吗? jQuery latest wont work; jQuery最新无法正常工作; unfortunately, and I really don't want to work with crazy weird API. 不幸的是,我真的不想使用疯狂的怪异API。 Ideally just plain JS. 理想的情况是纯JS。
I wrote small plan js switch .. in case you want custom css and require to handle event on toggle.. hope its help 我写了小计划的js开关..万一您想要自定义css并要求在切换时处理事件。
onload = function() {
document.getElementById("switch").addEventListener("click", toggle, false);
};
function toggle()
{
var sw = document.getElementById("switch");
var v = sw.style.cssFloat;
if( v=='right')
sw.style.cssFloat ="left";
else
sw.style.cssFloat = "right";
}
There is pure Css solutions for your question..This css toggle switch uses checkbox for keeping the toggle condition. 您的问题有纯CSS解决方案。此CSS切换开关使用复选框保持切换条件。 On if checked and off condition if not checked. 如果选中,则打开;如果未选中,则关闭。
If you do not want to use a checkbox and interested in multiple toggle conditions like tab and other flips.Use this switch. 如果您不想使用复选框并且对多种切换条件(例如制表符和其他翻转)感兴趣,请使用此开关。 Although I m not sure if this will go fine in mobile devices. 尽管我不确定这是否会在移动设备中正常运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.