我有一個(gè)滑鼠移入移出顯示隱藏的事件,但是滑鼠如果多次滑過(guò)就會(huì)執(zhí)行多次,如何在滑鼠移出事件執(zhí)行完畢後立刻停止事件?
$(".target").on('mouseenter',function() {
$(this).children('.p1').show(function(){
$(this).addClass('animated fadeInLeft');
$(this).removeClass('animated fadeInLeft');
})
});
$(".target").on('mouseleave',function() {
$(this).children('.p1').hide(function(){
$(this).addClass('animated fadeOutLeft');
$(this).removeClass('animated fadeOutLeft');
})
});
ringa_lee
題主如果要用只執(zhí)行一次的方法,用.one()
就行,但是一般jQuery的動(dòng)畫(huà)特效一定要考慮動(dòng)畫(huà)隊(duì)列的問(wèn)題,建議在執(zhí)行動(dòng)畫(huà)之前加上.stop()
方法來(lái)停止「進(jìn)入動(dòng)畫(huà)隊(duì)列但是未完全執(zhí)行完」的動(dòng)畫(huà)
你是想說(shuō)馬上中止動(dòng)畫(huà)吧,用 stop()
$(this).children('.p1').stop(true, true)
$(".target").off('mouseenter').on('mouseenter',function() {
雷雷});
$(".target").off('mouseenter').on('mouseleave',function() {
});