当用户将鼠标悬停在 div 上时,此 div 会增加大小。但是当用户从这个 div 中删除光标时如何减小大小。
var hoveredDiv;
$('.promoContent').hover(function () {
hoveredDiv = $(this).attr('id');
$('#' + hoveredDiv).animate({height: '100%'});
});
最佳答案
你可以使用
The .hover() method binds handlers for both mouseenter and mouseleave events. You can use it to simply apply behavior to an element during the time the mouse is within the element.
$('.promoContent').hover(function () {
$(this).animate({height: '100%'});
},function(){
$(this).animate({height: '50%'});
});
关于JQuery 在悬停时增加 div 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32320908/