完整代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/jquery.min.js"></script>
<style>
.smallbox{
width:20px;
height:20px;
text-align: center;
background:#333;
/* position:absolute; */
/* left:25px; */
/* top:25px; */
margin:5px;
display: none;
}
.bigbox{
width:150px;
height:150px;
background:#000000;
margin: 10px;
opacity: .1;
}
.pop{
width: 150px;
height: 150px;
background: red;
position: absolute;
right: 0px;
top: 0px;
display: none;
}
.active{
display: block;
}
.smallbox span{
display: block;
width: 100%;
height: 100%;
cursor: pointer;
}
</style>
</head>
<body>
<div class="pop"></div>
<div class="bigbox" key='A'></div>
<div class="bigbox" key='B'></div>
<div class="bigbox" key='C'></div>
<div class="smallbox" key="1" style="position: absolute;left: 25px; top: 25px;"><span></span></div>
<div class="smallbox" key="2" style="position: absolute;left: 50px; top: 40px;"><span></span></div>
<div class="smallbox" key="3" style="position: absolute;left: 80px; top: 220px;"><span></span></div>
<div class="smallbox" key="4" style="position: absolute;left: 120px; top: 180px;"><span></span></div>
<div class="smallbox" key="5" style="position: absolute;left: 80px; top: 80px;"><span></span></div>
<div class="smallbox" key="6" style="position: absolute;left: 120px; top: 350px;"><span></span></div>
<div class="smallbox" key="7" style="position: absolute;left: 80px; top: 370px;"><span></span></div> <script>
    $(document).ready(             function(){
const arceObj={A:['5','1','2'],B:['3','4'],C:['6','7']}
let arceDom={}
// 当前所在热区
let arceKey=''
                $(".bigbox").mouseover(
                        function(e){
// 判断是哪个热区
arceKey=$(e.target).attr('key')
arceDom=e.target
const arr =$('.smallbox')
//console.log(arr)
// 遍历这个数组 找出该热区下应该显示的小热区
arr.each(function(item){
const key=$(arr[item]).attr('key')
//console.log(key);
// 找到之后将这些smallbox元素显示
if($.inArray(key,arceObj[arceKey]) !=-1){//判断arceObj数组里是否存在key
$(arr[item]).show()
}
});
$(this).css("opacity","1")
                        }
                ); $(".smallbox").mouseover(
                        function(e){
$(arceDom).css("opacity","1")
// const arce=$(e.target).attr('key')
// console.log(arce)
// 当前元素的所有兄弟元素 可修改样式
// $(e.target).siblings()
const arr =$('.smallbox')
// 遍历这个数组 找出该热区下应该显示的小热区
arr.each(function(item){
const key=$(arr[item]).attr('key')
// 找到之后将这些smallbox元素显示
if(arceObj[arceKey].indexOf(key)!=-1){
$(arr[item]).show()
}
});
                        }
                );

             /*
// 反向找到当前小热区所在的大热区 key为小热区的key
function getArcekey(key){
                        for(var akey in arceObj){
                          for(var i=0;i<arceObj[akey].length;i++){
                            // 如果找到相同的key返回大热区的key
                            if(arceObj[akey][i]==key){
                              return akey
                            }
                          }
                        }
                      }
            */                 $(".bigbox").mouseout(
                        function(e){
                            $(".smallbox").hide();
$(this).css("opacity",".1")
                        }
                ); $(".smallbox span").hover(function(){
$(".pop").addClass("active") },function(){
$(".pop").removeClass("active")
});             }
    ); </script>
</body>
</html>

效果图:

解决同层hover事件重叠闪烁问题的更多相关文章

  1. 使用jQuery的hover事件在IE中不停闪动的解决方法

    在使用jQuery的hover事件时,经常会因为鼠标滑动过快导致菜单不停闪动的情况,相信很多朋友都遇到过自己做的纵向下拉菜单不停的收缩,非常的讨厌.今天在给一个网站设计菜单时也遇到了这个情况,结果在百 ...

  2. js中hover事件时候的BUG以及解决方法

    hover事件是我们在开发前段时候遇到的稀松平常的问题,但是有没有发现会出现有一个BUg,比如,你移动到一个元素上,让它执行一个方法,然后你快速的移入移出的时候,他会进行亮瞎你眼睛的频闪效果,而且跟得 ...

  3. jQuery中多个元素的Hover事件

    1.需求简介 jQuery的hover事件只是针对单个HTML元素,例如: $('#login').hover(fun2, fun2); 当鼠标进入#login元素时调用fun1函数,离开时则调用fu ...

  4. 用:hover伪类代替js的hover事件

    制作二级菜单要实现鼠标移动上去显示子菜单,鼠标移出子菜单隐藏,或者其他类似需求的地方,首先我会想到用jquery的hover事件来实现,如: $(".nav").hover(fun ...

  5. jQuery – 鼠标经过(hover)事件的延时处理

    一.关于鼠标hover事件及延时 鼠标经过事件为web页面上非常常见的事件之一.简单的hover可以用CSS :hover伪类实现,复杂点的用js. 一般情况下,我们是不对鼠标hover事件进行延时处 ...

  6. jquery hover事件只触发一次动画

    最近工作时遇到个关于动画的问题,如下: $("div").hover( function() { $(this).animate({"margin-top":& ...

  7. 分享一个jquery插件,弥补一下hover事件的小小不足

    hover事件有一个缺点:当你的鼠标无意划过一个dom元素(瞬间划过,这个时候用户可能不想触发hover事件),会触发hover事件 应该设置一个时差来控制hover事件的触发 比如jd左边的菜单 你 ...

  8. QT 托盘 hover事件捕捉

    1. QSystemTrayIcon hover事件 参考:https://stackoverflow.com/questions/21795919/how-to-catch-the-mousehov ...

  9. 获得触发hover事件的元素id

    例: <div class="menu"> <ul> <li> <a id="menu1"></a> ...

随机推荐

  1. (翻译) 使用Unity进行AOP对象拦截

    Unity 是一款知名的依赖注入容器( dependency injection container) ,其支持通过自定义扩展来扩充功能. 在Unity软件包内 默认包含了一个对象拦截(Interce ...

  2. 基于KNN的发票识别

    项目概况: 有一个PDF文件,里面的每页都是一张发票,把每页的发票单独存为一个PDF并用该发票的的发票号码进行文件的命名,发票号码需要OCR识别,即识别下图中红色方块的内容. 一:拆分PDF 现有一个 ...

  3. 科普 | ​生成对抗网络(GAN)的发展史

    来源:https://en.wikipedia.org/wiki/Edmond_de_Belamy 五年前,Generative Adversarial Networks(GANs)在深度学习领域掀起 ...

  4. [问题]java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized...

    java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized... 这个问题一般是因为升级MSYQL ...

  5. linux-aapt文件调用问题

    使用管理后台上传移动app安装包到服务器,出现异常问题,解决方案如下: 本地环境说明: 系统:linux(centos 64位) 远程工具:xshell 数据库:oracle 中间件:weblogic ...

  6. 使用SpringCloud将单体迁移至微服务

    使用SpringBoot构建单体项目有一段时间了,准备对一个老项目重构时引入SpringCloud微服务,以此奠定后台服务能够应对未知的业务需求. 现在SOA架构下的服务管理面临很多挑战,比如面临一个 ...

  7. Codeforces 1322C - Instant Noodles(数学)

    题目链接 题意 给出一个二分图, 两边各 n 个点, 共 m 条边, n, m ≤ 5e5. 右边的点具有权值 \(c_i\), 对于一个只包含左边的点的点集 S, 定义 N(S) 为所有与这个点集相 ...

  8. Spring中的设计模式:工厂方法模式

    导读 工厂方法模式是所有设计模式中比较常用的一种模式,但是真正能搞懂用好的少之又少,Spring底层大量的使用该设计模式来进行封装,以致开发者阅读源代码的时候晕头转向. 文章首发于微信公众号[码猿技术 ...

  9. Spring-Cloud-Netflix-系统架构

    目录 系统架构 概述 集中式架构 概述 特点 垂直拆分 概述 特点 系统架构分类 微服务 微服务的特点: 分布式服务: 微服务和分布式的区别: 微服务要面临的问题: springClould是什么 远 ...

  10. Modbus协议和应用开发介绍

    因业务需要了解Modbus协议的使用,因此对Modbus的协议,以及相应的C#处理应用进行了解,针对协议的几种方式(RTU.ASCII.TCPIP)进行了封装,以及对Modbus的各种功能码的特点进行 ...