我曾尝试在同一时间内fadeOut一个div和fadeIn另一个div。它可以在Firefox和IE(7-9)中正常工作,也可以在Chrome中工作。不过,在chrome中,在fadeOut之后,我的页面必须滚动到顶部,然后滚动到fadeIn。
我想作为一种情况下,没有滚动在谷歌浏览器,如在火狐和IE。
$("ul.main_news li:eq(0)").hover(function(){
$(".a").stop(true, true).fadeOut(300).promise().done(function(){
$(".b").stop(true, true).fadeIn();
});
$(this).removeClass("asew");
$(this).addClass("sdghe");
$("ul.main_news li:eq(1)").removeClass("sdghe");
$("ul.main_news li:eq(1)").addClass("asew");
});
$("ul.main_news li:eq(1)").hover(function(){
$(".b").stop(true, true).fadeOut(300).promise().done(function(){
$(".a").stop(true, true).fadeIn();
});
$(this).removeClass("asew");
$(this).addClass("sdghe");
$("ul.main_news li:eq(0)").removeClass("sdghe");
$("ul.main_news li:eq(0)").addClass("asew");
});
发布于 2012-10-08 23:53:45
你不想在任何地方使用stop()
方法!可能在fadeOut()
的回调中使用有问题!试试这个:
("ul.main_news li:eq(1)").hover(function(){
$(".b").stop(true, true).fadeOut(300).promise().done(function(){
$(".a").fadeIn();
});
发布于 2012-10-07 16:32:28
您应该使用promise()的代码实例
$(".b").stop(true, true).fadeOut(300).queue(function(){
$(".a").stop(true, true).fadeIn();
});
发布于 2012-10-07 18:43:35
您应该在不使用回调的情况下使用此代码:
$(".a").stop(true, true).fadeIn(300);
$(".b").stop(true, true).fadeOut(0);
https://stackoverflow.com/questions/12767119
复制相似问题