Is there a better way to write the JS for this? I'm asking because I read from somewhere that using .hover
isn't recommended. Also, if I move the mouse in and out of the box really fast, the box fades in and out the exact number of times I entered/left the box. How do I prevent this?
$(".project-mask").hover(
function() {
$(".thumbnail").fadeOut(300);
$(".description").fadeIn(300);
},
function() {
$(".thumbnail").fadeIn(300);
$(".description").fadeOut(300);
}
);
.project-mask { height:260px;position:relative;width:260px }
.thumbnail, .description { position:absolute;width:100% }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<article class="project">
<div class="project-mask">
<div class="thumbnail">
<img src="http://dummyimage.com/260x260/000/fff" height="260" width="260" />
</div>
<div class="description">
<p>blah blah blah</p>
</div>
</div>
</article>