As much as I hated the <blink>
tag, try this:
$.fn.blink = function(opts) {
// allows $elem.blink('stop');
if (opts == 'stop') {
// sets 'blinkStop' on element to true, stops animations,
// and shows the element. Return this for chaining.
return this.data('blinkStop', true).stop(true, true).show();
}
// we aren't stopping, so lets set the blinkStop to false,
this.data('blinkStop', false);
// load up some default options, and allow overriding them:
opts = $.extend({}, {
fadeIn: 100,
fadeOut: 300
}, opts || {} );
function doFadeOut($elem) {
$elem = $elem || $(this); // so it can be called as a callback too
if ($elem.data('blinkStop')) return;
$elem.fadeOut(opts.fadeOut, doFadeIn);
}
function doFadeIn($elem) {
$elem = $elem || $(this);
if ($elem.data('blinkStop')) return;
$elem.fadeIn(opts.fadeIn, doFadeOut);
}
doFadeOut(this);
return this;
};
// example usage - blink all links until you mouseover:
// takes advantage of the jQuery.one() function so that it only calls the
// stop blink once
$('a').blink({fadeIn: 500, fadeOut: 1500}).one('mouseover', function() {
$(this).blink('stop')
});
// 30 seconds after we started blinking, stop blinking every element we started:
setTimeout(function() {
$('a').blink('stop');
}, 30000);
// example that should do what you wanted:
$("#mydiv1,#mydiv2").blink().one('mouseover', function() {
$(this).blink('stop');
});