简体   繁体   中英

Alternative to jQuery mobile / Switch + Toggle btn

I wish to not USE 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; unfortunately, and I really don't want to work with crazy weird API. Ideally just plain JS.

I wrote small plan js switch .. in case you want custom css and require to handle event on toggle.. hope its help

   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";  
   }

JS Switch

There is pure Css solutions for your question..This css toggle switch uses checkbox for keeping the toggle condition. 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.

Switch without checkbox +toggle btn

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM