Lieutenant Dan
Lieutenant Dan

Reputation: 8274

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 a a mobile friendly; mobile first, simple Switch toggle button.

enter image description here

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.

Upvotes: 0

Views: 302

Answers (2)

Lucky
Lucky

Reputation: 17345

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

Upvotes: 0

Neha
Neha

Reputation: 1548

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

Upvotes: 1

Related Questions