首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用下拉菜单过渡效果(JS)

问禁用下拉菜单过渡效果(JS)
EN

Stack Overflow用户
提问于 2020-12-14 04:33:02
回答 1查看 157关注 0票数 0

在我的下拉菜单中有一个我想要完全禁用的过渡效果,这是我认为我必须更改的js代码。

代码语言:javascript
复制
    function(e) {
  if ((/input|textarea/i.test(e.target.tagName) ? !(32 === e.which || 27 !== e.which && (40 !== e.which && 38 !== e.which || t(e.target).closest(y).length)) : h.test(e.which)) && (e.preventDefault(), e.stopPropagation(), !this.disabled && !t(this).hasClass(u))) {
    var n = a._getParentFromElement(this),
      i = t(n).hasClass(f);
    if ((i || 27 === e.which && 32 === e.which) && (!i || 27 !== e.which && 32 !== e.which)) {
      var s = t(n).find(I).get();
      if (0 !== s.length) {
        var r = s.indexOf(e.target);
        38 === e.which && r > 0 && r--, 40 === e.which && r < s.length - 1 && r++, r < 0 && (r = 0), s[r].focus()
      }
    } else {
      if (27 === e.which) {
        var o = t(n).find(E)[0];
        t(o).trigger("focus")
      }
      t(this).trigger("click")
    }
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-14 04:49:49

可能是this post的副本this的副本

如果你不想跳过阅读,这里是你应该添加的CSS:

代码语言:javascript
复制
.collapsing {
    -webkit-transition: none;
    transition: none;
    display: none;
}

在发布问题之前,不要忘记先搜索答案。

编辑:您的站点使用JS/jQuery来完成此操作,这是正确的。该函数位于my-js.js文件中,如下所示:

代码语言:javascript
复制
$(document).ready(function(){
    $(".dropdown").hover(            
        function() {
            $('.dropdown-menu', this).not('.in .dropdown-menu').stop( true, true ).slideDown("low");
            $(this).toggleClass('open');        
        },
        function() {
            $('.dropdown-menu', this).not('.in .dropdown-menu').stop( true, true ).slideUp("low");
            $(this).toggleClass('open');       
        }
    );
});

您可以将slideDown和slideUp方法编辑为slideUp(0) (内部没有引号,因为它是一个数值),而不是‘slideUp(0)’。这实际上应该会禁用动画。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65280368

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档