jQuery褪色效果发生多次 [英] jQuery Fading effect occuring multiple times

查看:104
本文介绍了jQuery褪色效果发生多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简单的jQuery脚本,以在页脚上应用褪色效果.在发生鼠标悬停事件时,它以不透明度= 1淡入,在发生鼠标悬停事件时,它以不透明度0.01淡出.我已经在父div上应用了此效果.问题是,每次我将鼠标移到子元素上时,它都会触发该事件并使div多次闪烁.我该如何阻止它?我希望将鼠标悬停在父div上而不是将鼠标移到父div内时触发mouseover和mouseout事件.

I am trying to write a simple jQuery script to apply fading effect on footer. On mouseover event, it fades in with opacity = 1, and on mouse out event it fades out to opacity 0.01. I have applied this effect on parent div. The problem is, everytime I move mouse over child elements, it triggers the event and makes the div blink multiple times. How can I stop it? I want the mouseover and mouseout event to trigger when I hover over parent div and not when I move mouse inside the parent div.

这是情况

感谢您的任何帮助...:)

Thanks for any help in advance... :)

推荐答案

您应该可以使用stop()函数来防止这种情况: http://api.jquery.com/stop/

You should be able to use the stop() function to prevent this: http://api.jquery.com/stop/

$(this).stop().fadeTo("fast",1.00);
$(this).stop().fadeTo("fast",0.01);

http://jsfiddle.net/w7Vbu/7/

这篇关于jQuery褪色效果发生多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆