jquery - 淡入 jquery [不工作]

标签 jquery menu fadein jsfiddle

我是 jquery 新手,我的 fadeIn 不起作用。我做了一个JSFIDDLE这里。谢谢

$('#menu > li').on('mouseover', function(e){
  $(this).find("ul:first").fadeIn(120).finish();
  $(this).find('> a').addClass('active');
}).on('mouseout', function(e){
  $(this).find("ul:first").stop().finish().delay(500).fadeOut(120);
  $(this).find('> a').removeClass('active');
});

最佳答案

删除.finish():

$('#menu > li').on('mouseover', function(e){
  $(this).find("ul:first").fadeIn(120);
  $(this).find('> a').addClass('active');
}).on('mouseout', function(e){
  $(this).find("ul:first").stop().finish().delay(500).fadeOut(120);
  $(this).find('> a').removeClass('active');
});

fiddle :https://jsfiddle.net/YGB5G/47/

来自jQuery site :

When .finish() is called on an element, the currently-running animation and all queued animations (if any) immediately stop and their CSS properties set to their target values. All queued animations are removed.

关于jquery - 淡入 jquery [不工作],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30875471/

相关文章:

javascript - jQuery 菜单 - 在下拉悬停时保持菜单处于事件状态

javascript - 为什么CSS中的display none没有被fadein去掉?

jquery - 打开网站时调用脚本

javascript - jquery 表中的搜索和条目计数

javascript - 如何预览上传的图片作为div的背景图片?

css - 需要更改下拉 css 菜单以下拉

android - 如何禁用底部栏中已选择的项目

javascript - 如何从项目目录中读取javascript中的属性文件?

Jquery获取元素的特定类

javascript - jQuery根据Class获取ID,写入HTML并fadeIn