我想在悬停事件时隐藏 div 'sample' 并需要在鼠标移出时显示 div 'sample'
$('.secmenu').hover(function() {
$('.sample').css('opacity', '0');
if ($('.secmenu').mouseleave()) {
$('.sample').css('opacity', '1');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="" class="secmenu">click</a>
<div class="sample">
hello div sample text content hello div sample text content
</div>
最佳答案
$('.secmenu').mouseenter(function() {//hide div on mouse enter
$('.sample').hide();
}).mouseleave(function() {//show div on mouse leave
$('.sample').show();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="" class="secmenu">click</a>
<div class="sample">
hello div sample text content hello div sample text content
</div>
关于javascript - 在悬停事件上隐藏 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38118566/