Create On/Off Toggle Buttons From Any Elements - toggleButton.js

File Size: 5.06 KB
Views Total: 2834
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Create On/Off Toggle Buttons From Any Elements - toggleButton.js

The toggleButton.js jQuery plugin enables you to dynamically create on/off toggle buttons from any elements.

The toggle button provides 2 states (on and off) which can be used to toggle whatever you like.

How to use it:

1. Link to jQuery JavaScript library and the toggleButton.js plugin.

<script src="" 
<script src="jquery.togglebutton.js"></script>

2. Attach the function to the toggle element.

<a href="javascript:">Toggle Button</a>

3. Do something when you click the toggle button.

  on: function () {
    // ...
  off: function () {
    // ...
  both: function (oEvent) {
    // on or off

4. Set the on/off state of the toggle button.


5. Customize the styles of the toggle button that is active.

a.toggle_button__on {
  /* your styles here */

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