![](/img/trans.png)
[英]How to disable the radio button for a fixed interval of time after clicking them
[英]How to disable radio button after a time interval
這是我的PHP腳本功能
$xRadio = 0;<br>
echo"<script type='text/javascript' src='http://code.jquery.com/jquery-2.0.2.min.js'><br> </script>";
echo"<script type='text/javascript'>
$xRadio = setInterval(function(){ $('.radio').attr('disabled',true);},3000);
</script>";
這是我想在PHP中禁用的單選按鈕
echo "<td><input type='radio' class='radio' name='$i' value='A'>" . $row['opt_a'] . "</td>";
使用setTimeout()
,您只需調用一次函數。 將其包裝在$(document).ready()
函數中,因為在運行此腳本時我不確定DOM是否准備就緒。 使用jQuery的prop()
而不是attr()
$(document).ready(function(){
$xRadio = setTimeout(function(){
$('.radio').prop('disabled',true);
}, 3000);
});
對不起,如果我也沒有添加您的PHP,但這與問題無關。
只需嘗試修改后的代碼即可。
echo "<td><input type='radio' class='radio' name='$i' value='A'>" . $row['opt_a'] . "</td>";
$xRadio = 0;echo "<br>";
echo"<script type='text/javascript' src='http://code.jquery.com/jquery-2.0.2.min.js'><br> </script>";
echo"<script type='text/javascript'>
setInterval(function(){ $('.radio').attr('disabled',true);},3000);</script>";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.