How to temporarily disable a click handler in jQuery?

前端 未结 12 2041
不思量自难忘°
不思量自难忘° 2020-12-04 14:02

Say I have something like the following to trap the click event of a button:

$(\"#button_id\").click(function() {
  //disable click event
  //do something
           


        
12条回答
  •  忘掉有多难
    2020-12-04 14:32

    This example work.


    HTML code:

      
    Something

    jQuery:

        var fade = function(){
            $(".mask").fadeToggle(500,function(){
                $(this).parent().on("click",function(){
                    $(this).off("click");
                    fade();
                });
            });
        };
    
        $(".wrapper").on("click",function(){
            $(this).off("click");
            fade();     
        });
    

提交回复
热议问题