简体   繁体   English

在下一个元素鼠标悬停时隐藏活动 div

[英]Hide active div on next element mouse over

I want to hide the tooltips div which I will show on the div click so once mouse over on next div the previous div tooltips hide.我想隐藏我将在 div 单击时显示的工具提示 div,因此一旦鼠标悬停在下一个 div 上,上一个 div 工具提示就会隐藏。 But its hiding when mouse leave on the next div area.但是当鼠标离开下一个 div 区域时它会隐藏。

https://codepen.io/codepat007/pen/BazYXKo https://codepen.io/codepat007/pen/BazYXKo

My Code我的代码

 $(".tooltipsShow").click(function() { $(".tooltips").show(); }); $(".tooltipsShow").hover(function() { $(this).nextAll().eq(0).find(".tooltipsText").parent(".tooltips").hide(); });
 .tooltips { display: none; padding: 10px; position:absolute; top: 10%; left: 30%; background: green; color:#fff; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="tooltipsShow"> <p>Some text 1</p> </div> <div class="tooltipsShow"> <p>Some text 2</p> </div> <div class="tooltipsShow"> <p>Some text 3</p> </div> <div class="tooltipsShow"> <p>Some text 4</p> </div> <div class="tooltips"><p class="tooltipsText">I am tooltips</p></div>

Then just hide the tooltip div on hover然后在悬停时隐藏工具提示div

$(".tooltipsShow").hover(function() {
   console.log('hover');
  $(".tooltips").hide();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM