General class for using a button to toggle a class on a container.
Use
var t = new TOGGLE({
container: $('.toggle-container'),
button: $('.toggle-button'),
class: 'is-toggled',
onComplete: fn
})
Options
Pass an options object with the following keys:
- container - the element on which to toggle the class (required)
- button - the element to listen for a click (required)
- class - the class to toggle (optional - defaults to
is-open
) - onComplete - the function to run when toggle has finished (optional function(container, button), default false)