我在 jquery API 文档的帮助下制作了这个脚本,一切正常。
除了一件事,如果您离开悬停,我想完成当前事件(队列)。如果您离开某个 div,每个球都应该再次变得透明。我一直在寻找很长一段时间来实现这一点,但它没有帮助我。
也许这是一个愚蠢的问题,需要添加 1 行代码。但我希望你能帮我解决这个问题!
这是jsfiddle
这是jQuery代码:
$("#hulp").hover(function() {
$("#first").delay ( 100 );
$("#second").delay ( 200 );
$("#third").delay ( 300 );
$("#fourth").delay ( 400 );
$("#fifth").delay ( 500 );
$("#sixth").delay ( 600 );
$("#first, #second, #third, #fourth, #fifth, #sixth").queue(function() {
var that = $( this );
that.addClass("red");
that.dequeue ();
});
$("#fifth").delay ( 1000 );
$("#sixth").delay ( 800 );
$("#fifth, #sixth").queue(function() {
var that = $( this );
that.removeClass("red");
that.addClass("blue");
that.dequeue();
});
$("#fifth").delay ( 1200 );
$("#sixth") .delay ( 1000 );
$("#fifth, #sixth") .queue(function() {
var that = $( this );
that.removeClass("blue");
that.dequeue();
that.clearQueue();
});
});
$("#hulp2").hover(function() {
$("#first").delay ( 100 );
$("#second").delay ( 200 );
$("#third").delay ( 300 );
$("#fourth").delay ( 400 );
$("#fifth").delay ( 500 );
$("#first, #second, #third, #fourth, #fifth").queue(function() {
var that = $( this );
that.addClass("red");
that.dequeue ();
});
$("#first").delay ( 1400 );
$("#second").delay ( 1200 );
$("#third").delay ( 1000 );
$("#fourth").delay ( 800 );
$("#fifth").delay ( 600 );
$("#first, #second, #third, #fourth, #fifth").queue(function() {
var that = $( this );
that.removeClass("red");
that.addClass("blue");
that.dequeue();
});
$("#first").delay ( 2200 );
$("#second").delay ( 2000 );
$("#third") .delay ( 1800 );
$("#fourth").delay ( 1600 );
$("#fifth") .delay ( 1400 );
$("#first, #second, #third, #fourth, #fifth").queue(function() {
var that = $( this );
that.removeClass("blue");
that.dequeue();
that.clearQueue();
that.finish();
});
});