如果用户没有输入任何输入,如何在N分钟后使单选按钮变灰?
是否有jQuery方法或插件可以执行此操作?
谢谢!
答案 0 :(得分:1)
试试这个......
setTimeout(function(){
document.getElementById("your_radio_button_id").disabled = true;
},2000)//Instead of 2000 you can use whatever you want
希望它能运作
答案 1 :(得分:0)
我猜你问过这个,如果我没弄错的话:
<input type="radio" name="gender" value="male"><span class="radioButtonText">Male</span><br>
<input type="radio" name="gender" value="female"><span class="radioButtonText">Female</span><br>
<br />
<script type="text/javascript">
$(document).ready(function () {
//Timer Functionality
var myVar = setInterval(function () {myTimer()}, 4000);
function myTimer() {
$("input[name = gender]").attr('disabled', 'disabled');
$(".radioButtonText").css('color', 'grey');
}
//If user puts an input, stop Timer Functionality
$("input[name=gender]").click(function () {
clearTimeout(myVar);
});
});
</script>