Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created August 25, 2014 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/0fafaddf2fa6718393c3 to your computer and use it in GitHub Desktop.
Save yairEO/0fafaddf2fa6718393c3 to your computer and use it in GitHub Desktop.
jQuery plugin - add temporary class name
$.fn.addTempClass = function(tempClass, duration){
if( !tempClass )
return this;
return this.each(function(){
var $elm = $(this);
$elm.addClass(tempClass);
setTimeout(function(){
$elm.removeClass(tempClass);
}, duration || 100);
});
}
@yairEO
Copy link
Author

yairEO commented Aug 25, 2014

Adds some class (or classes) to an element for a specific duration, then removes it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment