Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created February 9, 2011 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaronpowell/818234 to your computer and use it in GitHub Desktop.
Save aaronpowell/818234 to your computer and use it in GitHub Desktop.
How to implement blink with jQuery
(function($) {
$.fn.blinky = function(args) {
var opts = { frequency: 1e3, count: -1 };
args = $.extend(true, opts, args);
var i = 0;
var that = this;
var dfd = $.Deferred();
function go() {
if(that.length == 0) {
return dfd.reject();
}
if(i == args.count) {
return dfd.resolve();
}
i++;
$(that).fadeOut().fadeIn();
setTimeout(go, args.frequency);
};
go();
return dfd.promise();
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment