Ake*_*Jha 0 javascript jquery events click
标题几乎描述了我的问题.我只需要在一秒钟内禁用点击事件,这样我就无法点击网页上的任何其他按钮.时间结束后,我可以再次点击任何地方.
禁用一秒钟的其他按钮也是可以接受的.
Roh*_*mar 11
试试吧,
$('#id').on('click',function(){
// let a common class(disable-btn) for each button which should be disabled for on second
$('.disable-btn').prop('disabled',true);
setTimeout(function(){
// enable click after 1 second
$('.disable-btn').prop('disabled',false);
},1000); // 1 second delay
});
Run Code Online (Sandbox Code Playgroud)
$('#id').on('click', function() {
// let a common class(disable-btn) for each button which should be disabled for on second
$('.disable-btn').prop('disabled', true);
setTimeout(function() {
// enable click after 1 second
$('.disable-btn').prop('disabled', false);
}, 1000); // 1 second delay
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="id">Click to disable other for 1 second</button>
<br/>
<button class="disable-btn">Will Disable for 1 sec</button>
<br/>
<button class="disable-btn">Will Disable for 1 sec</button>
<br/>
<button>Will not Disable</button>
<br/>
<button class="disable-btn">Will Disable for 1 sec</button>
<br/>Run Code Online (Sandbox Code Playgroud)
您可以#id通过添加一个来禁用按钮本身class="disable-btn"
| 归档时间: |
|
| 查看次数: |
6697 次 |
| 最近记录: |