gpt4 book ai didi

javascript - 需要防止双击焦点按钮同时保持以下按钮可点击的可点击按钮表的问题

转载 作者:行者123 更新时间:2023-11-30 12:52:11 25 4
gpt4 key购买 nike

我有一个可点击按钮列表,并使用标志变量来防止双击焦点按钮。该标志有效,我得到了预期的警报,说“你已经点击了那个”。问题是下面的按钮将被视为好像它也已被单击,我将再次收到警报。我不想要这个。

  var _clickFlag = true;

/* #Volunteers is a table. Each row on the table has a button that says "accept",
I pass the function the 'event' object which I use to get specific data from that table
row and send it to a database*/

$('#Volunteers').on('click','#accept', function(event){

//if clickFlag = true then the button hasn't been clicked yet.

if(_clickFlag){

//here I send some stuff to a database. I don't want to send it twice for the same
//row, which is why I need to prevent a double click

//set clickFlag to false to prevent double submission

_clickFlag = false;



}else{

//alert if the button has been clicked once already

alert("already accepted");
}


});

最佳答案

只需使用这个:

$( "#Volunteers").unbind( "click" );

这只会使按钮不可点击。

关于javascript - 需要防止双击焦点按钮同时保持以下按钮可点击的可点击按钮表的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20555053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com