这是我的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>";
答案 0 :(得分:3)
使用setTimeout()
,您只需要调用一次该函数。将其包装在$(document).ready()
函数中,因为在运行此脚本时我不确定DOM是否已准备就绪。使用jQuery的prop()
代替attr()
$(document).ready(function(){
$xRadio = setTimeout(function(){
$('.radio').prop('disabled',true);
}, 3000);
});
对不起,如果我不添加你的PHP,但这与问题无关。
答案 1 :(得分:0)
试试这个经过修改的代码。
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>";