亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - How to stop an event immediately after it has finished executing
ringa_lee
ringa_lee 2017-06-14 10:54:31
0
5
955

I have a mouse move-in and move-out show-hidden event, but if the mouse slides over multiple times, it will be executed multiple times. How can I stop the event immediately after the mouse move-out event is executed?

$(".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
ringa_lee

ringa_lee

reply all(5)
洪濤

If you want to use a method that only executes once, just use .one(). However, in general, jQuery animation special effects must consider the animation queue. It is recommended to add .stop() before executing the animation. Method to stop animations that "enter the animation queue but are not completely executed"

大家講道理
$(".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');
    })
    $(this).unbind();    //加一句這個(gè)取消當(dāng)前dom的所有綁定事件
});
黃舟

Add an e after

on, and you can use .one()This API will automatically delete it once.

Reference

漂亮男人

If you want to stop the animation immediately, use stop()

$(this).children('.p1').stop(true, true)
學(xué)習(xí)ing

$(".target").off('mouseenter').on('mouseenter',function() {

$(this).children('.p1').show(function(){
    $(this).addClass('animated fadeInLeft');
    $(this).removeClass('animated fadeInLeft');
})

});
$(".target").off('mouseenter').on('mouseleave',function() {

$(this).children('.p1').hide(function(){
    $(this).addClass('animated fadeOutLeft');
    $(this).removeClass('animated fadeOutLeft');
})

});

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template