jQuery Fading effect occuring multiple times

▼魔方 西西 提交于 2020-01-23 11:49:05

问题


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.

Here is the situation

Thanks for any help in advance... :)


回答1:


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/



来源:https://stackoverflow.com/questions/6224681/jquery-fading-effect-occuring-multiple-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!