javascript - 实现更改 fadeIn fadeOut 内容菜单 Jquery 的最佳方式

标签 javascript jquery menu fade

寻找使用 javascript (jQuery) 实现菜单的最佳方式,我可以在其中更改菜单上的内容,使用淡出 fadeIn 效果,在 html 中隐藏。

想法

Have a menu , when I click want to active the button and the content, and using a fadeOut effect and replace for the content that I clicked. ( Could add the active class for better play with css)

问题

The main problem I have is since it have a time to fadeOut and fadeIn the content appear before the other disappearing the other content.

寻找解决方案

I'm looking the best way to implement :

  • The menu, if "href" is the best way to get the content to show

  • Solve the main problem of the fade out fade in effect.Special if you're fast clicking between button, it seems to break (I increase a little the time in the example to check it better)

  • Add the class "active" in the menu and gallery

开始的小例子here

最佳答案

如果我正确理解您的问题,您希望在一个画廊消失而另一个画廊淡入时停止出现这种延迟。最简单的方法是隐藏当前显示的画廊(而不是 fadeOut) 然后 fadeIn 新选择的画廊。如果您将代码 javascript 更改为此,您会看到结果更加流畅。

  $('#menu li').click(function(event){
      event.preventDefault();
      var $this = $(this);
      var href=  $this.find('a').attr('href');
      $(".gallery").hide();
      $(href).fadeIn(1000);  
  });

关于javascript - 实现更改 fadeIn fadeOut 内容菜单 Jquery 的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6968162/

相关文章:

c++ - 扩展外部应用程序的菜单

javascript - Webpack v4 在单个页面上有多个条目, block 被不必要地重复

JavaScript 类型注解

javascript - 已选择行选择时选中/取消选中复选框

javascript - jQuery 验证 - 检查字符串是否具有 unicode 或空格字符不起作用

java - 带有整数和用户输入的 ArrayList

javascript - Google Analytics 异常跟踪

javascript - 当脚本选择单选按钮时,paper-radio-group-changed 不触发

javascript - 从 div 获取复选框 id 和值的列表并将其传递给 Controller

java - 调用 menuitems 来触发单独的代码块