西西木科技丨Shopify开发机构 2023-01-13 05:28 采纳率: 96.4%
浏览 72
已结题

jQuery hover() 出现页面刷新触发的bug

jQuery hover() 出现页面刷新触发的bug

点击菜单切换页面时 会有一定概率出现没有hover到菜单,#mega-off-grid-living无故弹出的bug

<div class="megamenu-event" id="mega-off-grid-living">
               <div class="megamenu-event-box">                                               
                <a href="" class="event1" style="background:#d9d9d9;">
                   <img src="" class="event-icon">
                   <p class="event-text">RV<svg viewBox="0 0 14 10" fill="none" aria-hidden="true" focusable="false" role="presentation" class="icon icon-arrow" xmlns="http://www.w3.org/2000/svg">
  <path fill-rule="evenodd" clip-rule="evenodd" d="M8.537.808a.5.5 0 01.817-.162l4 4a.5.5 0 010 .708l-4 4a.5.5 0 11-.708-.708L11.793 5.5H1a.5.5 0 010-1h10.793L8.646 1.354a.5.5 0 01-.109-.546z" fill="currentColor">
</path></svg>

<a href="" class="event2" style="background:#d9d9d9;"> <img src="" class="event-icon"> <p class="event-text">Cabin<svg viewBox="0 0 14 10" fill="none" aria-hidden="true" focusable="false" role="presentation" class="icon icon-arrow" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.537.808a.5.5 0 01.817-.162l4 4a.5.5 0 010 .708l-4 4a.5.5 0 11-.708-.708L11.793 5.5H1a.5.5 0 010-1h10.793L8.646 1.354a.5.5 0 01-.109-.546z" fill="currentColor"> </path></svg>

<a href="" class="event3" style="background:#d9d9d9;"> <img src="" class="event-icon"> <p class="event-text">Home Solar<svg viewBox="0 0 14 10" fill="none" aria-hidden="true" focusable="false" role="presentation" class="icon icon-arrow" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.537.808a.5.5 0 01.817-.162l4 4a.5.5 0 010 .708l-4 4a.5.5 0 11-.708-.708L11.793 5.5H1a.5.5 0 010-1h10.793L8.646 1.354a.5.5 0 01-.109-.546z" fill="currentColor"> </path></svg>

<a href="" class="event4" style="background:#d9d9d9;"> <img src="" class="event-icon"> <p class="event-text">Marine<svg viewBox="0 0 14 10" fill="none" aria-hidden="true" focusable="false" role="presentation" class="icon icon-arrow" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.537.808a.5.5 0 01.817-.162l4 4a.5.5 0 010 .708l-4 4a.5.5 0 11-.708-.708L11.793 5.5H1a.5.5 0 010-1h10.793L8.646 1.354a.5.5 0 01-.109-.546z" fill="currentColor"> </path></svg>

  • 写回答

4条回答 默认 最新

  • CSDN专家-showbo 2023-01-13 12:45
    关注

    是鼠标快速移动会出现bug,如下图

    img

    出现这个问题看下面截图,注释了样式.megamenu-event中opacity:0(去掉opacity的动画效果),鼠标移出nav菜单时,#mega-off-grid-living不是马上消失(visibility:hidden在动画结束最后才会生效),所以只要在消失前快速移动到其他菜单下的子菜单,实际移动到的还是#mega-off-grid-living这个层,触发了绑定到这个容器中的hover,加上了megadisplay又显示出来了。

    img

    将样式中visibility:hidden改为display:none,同时megadiplay样式中的visibility:visible改为display:block就可以了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 1月26日
  • 已采纳回答 1月18日
  • 创建了问题 1月13日

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看