Toggle Parent
Simple component to toggle a class on parentNode of an element. When activated
a backdrop element (.toggle-parent-backdrop
) is added that will remove the
class when clicked.
Installation
With component:
$ component install mjlescano/toggle-parent
Example
Toggle Menu option 1 option 2 option 3
var ToggleParent = ; var button = document; // Every time 'button' is pressed, the class 'active' will// be toggled on '#dropdown-container'var dropdown = button; // Toggle programaticallydropdown
Options
Options that can be passed as a second argument to new ToggleParent(button, opts)
- parent: Element to toggle the class (Default: button.parentNode)
- toggleClass: Class name to be toggled (Default:
active
)
API
- .show(): Add
toggleClass
toparent
- .hide(): Remove
toggleClass
fromparent
- .toggle(): Toggle
toggleClass
onparent
- .destroy(): Remove ToggleParent instance, with all the events attached.
License
MIT