<input type="button" onclick="return saveValues();" value="<?php echo "values" ?>" class="silver_button_big">
在上面停止多点点击我试过这样的事情。
my_toggle_var = 0; // your global variable which u can use to play
function saveValues() {
if (my_toggle_var == 0)
{
ic.do.something();
my_toggle_var = 1; // You can move it up down based on your need....
}
},
something : function(){
//some code
//these code lead to run some jar file
// data insertion into DB(using mysql)
}
但这无法解决我在上述情况下的问题,我可以说可能存在某种浏览器缓存问题。 有人可以帮帮我吗。
最佳答案
只需设置 disabled="disabled"
和 readonly="readonly"
属性:
// Attach the click handler
$(".silver_button_big").on("click", function() {
var $this = $(this);
// Disable button
$this.attr({"disabled": "disabled", "readonly": "readonly"});
// Do something async
setTimeout(function() {
// Enable the button back
$this.removeAttr("disabled readonly");
}, 1000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" value="Click me" class="silver_button_big">
关于javascript - 在 javascript if(confirm ) 条件确认之前,如何防止多次单击 onclick 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26903153/