여러 답변의 조언에 따라 hover ()
사용에서 mouseover ()
로 마지막으로 mouseenter ()
및 mouseleave () <로 전환했습니다. / code>. 하지만 여전히 깜박이는 문제가 발생합니다 (
.staff_img
이미지 요소를 가리키면 mouseleave ()
이벤트가 매초마다 계속 발생합니다. 내가 뭘 잘못하고 있는가?)
JS
$('.staff_img').mouseenter(function() {
$(this).siblings('.staff_hover').fadeIn();
});
$('.staff_img').mouseleave(function() {
$(this).siblings('.staff_hover').fadeOut();
});
HTML
<img class="staff_img" />
<div class="staff_hover"></div>
CSS
.staff img {
width: 100%;
max-width: 100%;
height: auto;
}
.staff_hover {
display: none;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.6);
}