Created
July 23, 2017 07:05
-
-
Save tito10047/6e7e96cffeb94aa7acdde85082fd4401 to your computer and use it in GitHub Desktop.
jquery set class if not has already
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
| $.fn.setClass = function(classes){ | |
| classes = classes.split(" "); | |
| this.each(function () { | |
| for(var i=0;i<classes.length;i++){ | |
| if (!$(this).hasClass(classes[i])){ | |
| $(this).addClass(classes[i]); | |
| } | |
| } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment