Skip to content

Instantly share code, notes, and snippets.

@lutzissler
Created June 3, 2013 09:58
Show Gist options
  • Save lutzissler/5697224 to your computer and use it in GitHub Desktop.
Save lutzissler/5697224 to your computer and use it in GitHub Desktop.
Flash/blink elements by fading in/out. Use it with care!
$.fn.flash = function (options) {
options = $.extend({
animation: 200,
off: 0,
on: 1000
}, options || {});
var elems = $(this),
f = function () {
elems
.animate({opacity: 0}, options.animation)
.delay(options.off)
.animate({opacity: 1}, options.animation)
.queue(function () {
setTimeout(f, options.on);
$(this).dequeue();
});
};
setTimeout(f, options.on);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment