0

我有以下 jquery 来制作所有对象,但悬停的对象会淡出然后淡出。但是,我希望悬停的元素立即淡化为完全不透明,而不是等待其他元素淡出。

$('a').bind('mouseenter',function(){
        $(this).fadeTo(0,1);
        $('a').not($(this)).fadeTo('fast', 0.25);
    }).bind('mouseleave',function(){
        $('a').fadeTo('slow', 1.0);
    });​

http://jsfiddle.net/cutcopypaste/jQmZ3/1/

4

2 回答 2

0

如果您只需要“自动聚焦”悬停的元素,请使用$.show()将元素直接带到前台。这主要是因为你不能再fade in有这个数量,因此你有你想要的效果。

$('a').bind('mouseenter',function(){
    $(this).show();
    $('a').not($(this)).fadeTo('fast', 0.25);
}).bind('mouseleave',function(){
    $('a').fadeTo('slow', 1.0);
});

http://jsfiddle.net/userdude/jQmZ3/2/

于 2012-07-05T00:47:50.020 回答
0

尝试http://jsfiddle.net/jQmZ3/3/ ...在所有“a”元素的效果队列上使用停止。

$('a').bind('mouseenter',function(){
    $('a').stop();                
    $(this).fadeTo(0,1);
    $('a').not($(this)).fadeTo('fast', 0.25);
}).bind('mouseleave',function(){
    $('a').fadeTo('slow', 1.0);  
});​
于 2012-07-05T00:15:49.577 回答