JS:
$.fn.blink = function(times, duration) {
times = times || 2;
while (times--) {
this.fadeTo(duration, 0).fadeTo(duration, 1);
}
};
这使得闪烁的文本。最后眨眼我想执行一个函数,所以我改变了它:
$.fn.blink = function(times, duration, callback) {
times = times || 2;
while (times--) {
this.fadeTo(duration, 0).fadeTo(duration, 1);
}
if (typeof callback == 'function') { // make sure the callback is a function
callback.call(this); // brings the scope to the callback
}
};
回调的执行不在正确的位置。它似乎在闪烁开始时被触发。任何想法如何在最后闪烁时调用该函数?