简体   繁体   中英

How to block/shut down click action for 1 second

I have some problem, i need to block/shut down some click action for some little time. What i'm trying to do is fire all actions after my click, but block this click when this actions is under procesing. So this is my code, thx for help:

carousel_controls_buttons.live('click', function(e){
    carousel_controls_buttons.attr('disabled', 'disabled');
    setTimeout(function(){
        e.preventDefault();
        $(xml).find("main_menu").each(function (){
           // some actions
        });
        carousel_controls_buttons.removeAttr('disabled');
    }, 450);
});

I am presuming you are wanting something like this:

$(document).ready(function () {
    carousel_controls_buttons.attr('disabled', 'disabled');
    setTimeout(function(){
        carousel_controls_buttons.removeAttr('disabled');
    }, 1000);

    carousel_controls_buttons.live('click', function(e){
        e.preventDefault();
        $(xml).find("main_menu").each(function (){
        // some actions
        });
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM