gpt4 book ai didi

javascript - 无法在 mouseout 上运行 jQuery 效果

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:50:51 25 4
gpt4 key购买 nike

我不知道为什么,但是悬停“out”函数中的 animate() 似乎是从 0 值开始的,而不是 16 应该是通过悬停“in”功能设置:

  $.fx.step.textShadowBlur = function(fx) {
$(fx.elem).css({textShadow: '0 0 ' + Math.floor(fx.now) + 'px #000'});
};

$('a').hover(function(){
$(this).stop().animate({textShadowBlur:16}, {duration: 400});
}, function(){
$(this).stop().animate({textShadowBlur:0}, {duration: 900});
});

所以我在鼠标移开时看到突然的文本阴影变化,没有动画

我做错了什么?

jsfiddle


好的,我修好了。这似乎是带有步骤函数定义或其他东西的 jquery 错误。无论如何这都行得通:

  $('a').hover(function(){
$(this).stop().animate({nothing:16}, {duration: 400, step: function(now, fx){
$(this).css({textShadow: '0 0 ' + Math.floor(fx.now) + 'px #000'});
}});
}, function(){
$(this).stop().animate({nothing:0}, {duration: 900, step: function(now, fx){
$(this).css({textShadow: '0 0 ' + Math.floor(fx.now) + 'px #000'});
}});
});

最佳答案

看起来像是语法问题

$('a').hover(function() {
$(this).stop().animate({textShadowBlur: 16}, {duration: 400});
// remove the extra }});
}, function() {
$(this).stop().animate({textShadowBlur: 0}, {duration: 900});
});

<罢工>

编辑

看起来您已经找到了解决方法,这里有一个选项可以使用 css 3 转换来实现此效果:

fiddle

a {
font-size:40px;
text-shadow:0 0 0 #000;
-webkit-transition:text-shadow .9s linear;
}
a:hover {
text-shadow:0 0 16px #000;
-webkit-transition:text-shadow .4s linear;
}

关于javascript - 无法在 mouseout 上运行 jQuery 效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7015530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com