Created
August 25, 2014 15:32
-
-
Save yairEO/0fafaddf2fa6718393c3 to your computer and use it in GitHub Desktop.
jQuery plugin - add temporary class name
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
$.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); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adds some class (or classes) to an element for a specific duration, then removes it