简体   繁体   中英

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. But its hiding when mouse leave on the next div area.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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