Disabling links to stop double-clicks in JQuery

前端 未结 16 753
别跟我提以往
别跟我提以往 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 11:55

    Yeah, set a value to keep track of this:

    $("a").click(function (){
      if( $(this).data("clicked") ){
        return false;
      }
      $(this).data("clicked", true);
      return true;
    });
    

提交回复
热议问题