Created
December 1, 2014 14:05
-
-
Save ksloan/d5ec0249589a1eaa3b36 to your computer and use it in GitHub Desktop.
jQuery plugin to fade out element after certain amount of time
This file contains hidden or 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.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