Skip to content

Instantly share code, notes, and snippets.

@tito10047
Created July 23, 2017 07:05
Show Gist options
  • Select an option

  • Save tito10047/6e7e96cffeb94aa7acdde85082fd4401 to your computer and use it in GitHub Desktop.

Select an option

Save tito10047/6e7e96cffeb94aa7acdde85082fd4401 to your computer and use it in GitHub Desktop.
jquery set class if not has already
$.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