Skip to content

Instantly share code, notes, and snippets.

@ksloan
Created December 1, 2014 14:05
Show Gist options
  • Save ksloan/d5ec0249589a1eaa3b36 to your computer and use it in GitHub Desktop.
Save ksloan/d5ec0249589a1eaa3b36 to your computer and use it in GitHub Desktop.
jQuery plugin to fade out element after certain amount of time
$.fn.flash = function(dur) {
var $el = this;
setTimeout(function() {
$el.fadeOut('slow', function() {
$el.remove()
})
}, dur)
}
// example: fade out after 5 seconds
$('div').prependTo('body').flash(5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment