Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add temporary class to HTML element
$(document).ready(function () {
$.fn.extend({
tmpClass: function (className, duration) {
var elements = this;
setTimeout(function () {
elements.removeClass(className);
}, duration);
return this.each(function () {
$(this).addClass(className);
});
}
});
// use of this function
$("#about h1").tmpClass("shake animated", 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment