Created
November 3, 2017 14:38
-
-
Save nonsponsored/2de03fa54f1a8d48d770b110afe67f40 to your computer and use it in GitHub Desktop.
Function: Toggle Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var toggleClass = function (trigger , cssClass) { | |
| 'use strict'; | |
| [].map.call(document.querySelectorAll(trigger), function(toggleTrigger){ | |
| toggleTrigger.addEventListener('click', function() { | |
| this.classList.toggle(cssClass); | |
| }); | |
| }); | |
| }; | |
| document.addEventListener('DOMContentLoaded', function() { | |
| toggleClass('.js-trigger' , 'cssClass'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment