Multi state Toggle Switch Plugin with jQuery SwitchStateButton - Download Multi-state Toggle Switch Plugin with jQuery - SwitchStateButton

Download Multi-state Toggle Switch Plugin with jQuery – SwitchStateButton

Posted on

This time I will share jQuery Plugin and tutorial about Multi-state Toggle Switch Plugin with jQuery – SwitchStateButton, hope it will help you in programming stack.

Multi state Toggle Switch Plugin with jQuery SwitchStateButton - Download Multi-state Toggle Switch Plugin with jQuery - SwitchStateButton
File Size: 4.09 KB
Views Total: 6465
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   



SwitchStateButton is a very simple jQuery plugin that helps you creates toggle switches with support for multiple option states.

How to use it:

1. Include the tsb.js file after the jQuery JavaScript as shown in the code snippet below.

1 <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
2 <script src="js/tsb.js"></script>

2. Render a basic toggle switch with 3 states inside the container you specify.

1 $("#selector").threestatebutton({
2   statecount: 3,
3   state: 1
4 });

3. Output the selected state.

1 <span id="output">Output: state 1</li>
1 function stateChanged(state, source) {
2   var nb = $(source).attr("id").substring(6);
3   var dispid = "#output" + nb;
4   $(dispid).text("Output " + nb + ": state " + state);
5 }
1 $("#selector").threestatebutton({
2   statecount: 3,
3   state: 1,
4   stateChanged: stateChanged
5 });

4. Apply your own CSS to the toggle switch.

01 .tsb-casing {
02   background-color: #4CD964;
03   border-color: #ECF0F1;
04   border-width: 1px 1px 1px 1px;
05   border-style: solid;
06   width: 1em;
07   border-radius: 10px;
08   position: relative;
09 }
10  
11 .tsb-state {
12   width: 20px;
13   height: 1em;
14   position: absolute;
15 }
16  
17 .tsb-ball {
18   background-color: #fff;
19   width: 1em;
20   height: 1em;
21   border-radius: 1em;
22   position: absolute;
23   vertical-align: central;
24   left: 0px;
25 }

This awesome jQuery plugin is developed by Arthur0g. For more Advanced Usages, please check the demo page or visit the official website.




source : jqueryscript.net