toggle
A toggle UI element.
Installation
$ component install segmentio/toggle
Example
var Toggle = ; var toggle = ;documentbody; togglevalue; // false togglevaluetrue;togglevalue; // true toggle;togglevalue; // false
API
Toggle(value, el)
Create a new toggle with an optional starting value
and optional el
to use instead of creating one.
#el
The toggle's DOM element.
#value(val)
Get or set the value of the toggle.
#name(name)
Set the toggle's internal checkbox's name, so forms can be submitted properly.
#toggle()
Toggle the value of the toggle.
#label(on, off)
Set the on and off labels's HTML.
#addClass(name)
Add a class to the toggle's element.
#removeClass(name)
Remove a class from the toggle's element.
License
MIT