我有一个 html 按钮,我想用 jquery 禁用它,在它被点击后大约 10 秒后我想启用它。
$('#test').click(function(){
$("#test").attr("disabled", true);
$('#test').html('Bitte warten..<img src="<?=CDN('/icons/loading/loading5.gif')?>" />');
});
我的计时器部分有问题。
我知道有类似 setInterval(function() {}, 5000);
的东西,但这会一遍又一遍。
最佳答案
您可以使用 setTimout在间隔后启用按钮。
$('#test').click(function(){
$("#test").attr("disabled", true);
setTimout(function(){
$("#test").attr("disabled", false);
}, 10000);
$('#test').html('Bitte warten..<img src="<?=CDN('/icons/loading/loading5.gif')?>" />');
});
关于jquery - 使用 JQuery 禁用 Html 按钮一段时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15609728/