你的$(this)在脈衝函數中並不是你所想象的。它只會在外部懸停聲明中起作用。你能解決這個問題是這樣的:
$(document).ready(function(){
$('#menu').find('.category-holder').hover(function(){
var that = $(this);
$('#menu').data('pulsating',true);
function pulse(){
if(!$('#menu').data('pulsating')) return;
that.children().eq(0).delay(100).animate({opacity: '1'},400);
that.children().eq(1).delay(200).animate({opacity: '1'},400);
that.children().eq(2).delay(300).animate({opacity: '1'},400);
that.children().eq(3).delay(400).animate({opacity: '1'},400);
that.children().eq(4).delay(500).animate({opacity: '1'},400);
that.children().eq(5).delay(600).animate({opacity: '1'},400);
that.children().eq(6).delay(700).animate({opacity: '1'},400);
that.children().eq(0).animate({opacity: '0.3'},400);
that.children().eq(1).animate({opacity: '0.3'},400);
that.children().eq(2).animate({opacity: '0.3'},400);
that.children().eq(3).animate({opacity: '0.3'},400);
that.children().eq(4).animate({opacity: '0.3'},400);
that.children().eq(5).animate({opacity: '0.3'},400);
that.children().eq(6).animate({opacity: '0.3'},400,pulse);
}
pulse();
}, function(){
$('#menu span:first').animate({opacity: '0.5'}, 400);
$('#menu').data('pulsating',false);
});
});
片刻 - 迷惑了第二個環節... – Rahil
究竟是什麼問題?你到底在想什麼? – mechalynx
@ivy_lynx更新 – Rahil