2015-03-19 75 views
1

這是我的客戶網站http://www.tswanda.co.zw/campaigns/tswanda-childrens-home/當你點擊貢獻時,一個彈出窗口出現與捐贈按鈕,如果你點擊捐贈按鈕2,3或4次,它再次提交值爲結帳。在點擊一次後禁用提交按鈕

我想要一旦提交一筆錢就可以禁用按鈕,請你幫我解決我試圖使用Disabling links to stop double-clicks in JQuery的代碼,但沒有任何工作適合我。

任何幫助將非常感激。

<script type="text/javascript"> 
     function do_nothing() { 
      return false; 
      } 

      // prevent a second click for 10 seconds. :) 
       jQuery('.edd-add-to-cart').live('click', function(e) { 
        jQuery(e.target).click(do_nothing); 
         setTimeout(function(){ 
        jQuery(e.target).unbind('click', do_nothing); 
        }, 50000); 
        }); 


    </script> 
+1

分享你已經試過 – mohamedrias 2015-03-19 11:11:59

+0

感謝檢查sir..i添加代碼 – Abhi 2015-03-19 11:15:24

+1

看看這個小提琴http://jsfiddle.net/L1y2xmhx/ – 2015-03-19 11:26:13

回答

1

點擊時,您可以禁用按鈕,5秒後重新啓用它:

  jQuery('.edd-add-to-cart').live('click', function(e) { 
      var element = $(this); 
      jQuery(e.target).click(do_nothing); 
      element.attr("disabled", "disabled"); 
      setTimeout(function(){ 
       element.removeAttr("disabled"); 
      }, 50000); 
      }); 
+0

我試過但它不適合我先生 – Abhi 2015-03-19 11:37:19

0

試試這個

<input type="submit" name="Submit" value="Submit" onclick="this.disabled=true; this.value='Please Wait...';" /> 
0

內,您的單擊處理程序,你要綁定另一個點擊事件到目標。你正在刪除特定的點擊處理程序。

而是嘗試通過設置disabled屬性禁用該按鈕並將其刪除。

function do_something() { 
    alert("doing something"); 
} 

// prevent a second click for 10 seconds. :) 

jQuery('.edd-add-to-cart').live('click', function (e) { 
     var self = this; 
     $(this).attr("disabled", "disabled"); 
     do_something(); 
     setTimeout(function() { 
      $(self).removeAttr('disabled'); 
     }, 10000); 
    }); 

DEMO