使用带有开关按钮的jQuery自动刷新网页
我想使用带有开关按钮的jQuery自动刷新我的网页。然而,我尝试了我的代码,但它根本不起作用。有人知道有什么问题吗使用带有开关按钮的jQuery自动刷新网页,jquery,button,refresh,Jquery,Button,Refresh,我想使用带有开关按钮的jQuery自动刷新我的网页。然而,我尝试了我的代码,但它根本不起作用。有人知道有什么问题吗 <script> $(document).ready(function(){ $("#btnautorefreshon").click(function(){ setTimeout(function() { location.reload() },1500); }); }); </script>
<script>
$(document).ready(function(){
$("#btnautorefreshon").click(function(){
setTimeout(function() { location.reload() },1500);
});
});
</script>
$(文档).ready(函数(){
$(“#btnautorefreshon”)。单击(函数(){
setTimeout(函数(){location.reload()},1500);
});
});
以下是开关按钮的代码:
<div class="page-header-actions" data-toggle="buttons" role="group">
<label class="btn btn-outline btn-primary active">
<input type="radio" name="options" autocomplete="off" value="autorefreshoff" checked />
<i id="btnautorefreshoff" class="icon wb-check text-active" aria-hidden="true"></i> Auto Refresh Off
</label>
<label class="btn btn-outline btn-primary">
<input type="radio" name="options" autocomplete="off" value="autorefreshon" />
<i id="btnautorefreshon" class="icon wb-check text-active" aria-hidden="true"></i> Auto Refresh on
</label>
</div>
自动刷新关闭
自动刷新
谢谢。自动完成的单选按钮是html中的一个
输入
标记,因此您只需重新调整选择器标签的焦点,通过向输入本身添加唯一的id来解决此问题
/*$(“.btn”)。在({
“单击”:函数(){
如果($('input#refreshon')。是(':checked')){
console.log('checked');
setTimeout(函数(){
location.reload();
}, 1500);
}
}
}); */
$('input#refreshon')。在({
“单击”:函数(){
console.log('checked');
setTimeout(函数(){
location.reload();
}, 1500);
}
});代码>
自动刷新关闭
自动刷新
有人知道这些问题吗?