jQuery click events firing multiple times

后端 未结 25 2240
不知归路
不知归路 2020-11-22 11:01

I\'m attempting to write a video poker game in Javascript as a way of getting the basics of it down, and I\'ve run into a problem where the jQuery click event handlers are f

25条回答
  •  长情又很酷
    2020-11-22 11:27

    All the stuff about .on() and .one() is great, and jquery is great.

    But sometimes, you want it to be a little more obvious that the user isn't allowed to click, and in those cases you could do something like this:

    function funName(){
        $("#orderButton").prop("disabled", true);
        //  do a bunch of stuff
        // and now that you're all done
        setTimeout(function(){
            $("#orderButton").prop("disabled",false);
            $("#orderButton").blur();
        }, 3000);
    }
    

    and your button would look like:

    
    

提交回复
热议问题