Here is my php script function
$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>";
and here is the radio button which i want to disable in php
echo "<td><input type='radio' class='radio' name='$i' value='A'>" . $row['opt_a'] . "</td>";
Use setTimeout()
, you only need to call the function once. Wrap it in a $(document).ready()
function, as I'm not sure the DOM is ready when you are running this script. Use jQuery's prop()
instead of attr()
$(document).ready(function(){
$xRadio = setTimeout(function(){
$('.radio').prop('disabled',true);
}, 3000);
});
Excuse me if I don't add your PHP as well, but it is irrelevant for the question.
Just try out this modified code.
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>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.