Created
July 30, 2019 07:43
-
-
Save hidegh/c3e16685723ba6e6dd91293774011a52 to your computer and use it in GitHub Desktop.
Allows to toggle/add/remove classes of an HTML element...
This file contains 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
$(document).on('click', '[data-toggle="class"]', function () { | |
var $target = $($(this).data('target')); | |
var toggleClasses = $(this).data('toggle-classes'); | |
if (toggleClasses) | |
$target.toggleClass(toggleClasses); | |
var addClass = $(this).data('add-classes'); | |
if (addClass) | |
$target.addClass(addClass); | |
var removeClass = $(this).data('remove-classes'); | |
if (removeClass) | |
$target.removeClass(removeClass); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment