Bootstrap下拉菜单(dropdown)改为hover效果

$(".dropdown-toggle").on("mouseenter",function(){

  if($(this).parent().is(".open")){

    return;

  }

  $(this).dropdown('toggle');

})

$(".dropdown").on("mouseleave",function(){

  if($(this).is(".open")){

    $(this).find('.dropdown-toggle').dropdown('toggle');

  }

})


升级版:

$(".dropdown-toggle").on("mouseenter",function(){

if($(this).parent().is(".open")){

return;

}

$(this).dropdown('toggle');

clearTimeout(timer);

})

$(".dropdown").on("mouseleave",function(){

if($(this).is(".open")){

$this = $(this);

timer=setTimeout(function(){

// clearTimeout(timer);

$this.find('.dropdown-toggle').dropdown('toggle');

// alert('1');

},500)

}

})

$(".dropdown-menu").mouseenter(function(){

clearTimeout(timer);

})

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,878评论 0 23
  • 今天是简书一哥彭小六的最后一堂课,关于个人IP。具体内容我就不贴在简书了,明天会把内容发到群里。这里只说三点感受。...
    虎七七阅读 865评论 1 6
  • 历经数年,发现现今的结局是自己的问题,要多敞开心扉,多跟人交流,太过封闭总是无用。
    果乐C阅读 409评论 0 0
  • 生活中的每一物 都是故事 有的尘封在那里 有的珍藏在那里 有的… 遗忘在那里 闲暇时光 借着一缕灵感 把它们 变成...
    Aliceflorida阅读 377评论 3 3
  • 行者顺达 婚姻如鞋,走不出怪圈 婚姻如衣,难于抵挡风雨 婚姻如床,一生的睡梦难醒 婚姻如被,盖不住满身创伤 婚姻如...
    行者顺达阅读 204评论 1 1