Disabling links to stop double-clicks in JQuery

前端 未结 16 784
别跟我提以往
别跟我提以往 2020-12-02 11:13

How would I disable all links with the button class after they are clicked once? I\'d like to be able to do this in one place, and not have to change all of the

16条回答
  •  无人及你
    2020-12-02 12:09

    You always make a big hassle over a sipmple thing.

    Set delayer self resetting variable when first click. That disables second clicks over some time. Simple!

        var formvar=1;
    
    $('#myForm').submit(function() { 
        if(formvar==1) 
            {
            $(this).ajaxSubmit(options); // or do what ever normally do
    
            setTimeout(function(){formi=1}, 3000);
            formvar=0;
            }
        else alert("no dbl clicking");
    
    
        }); 
    

提交回复
热议问题