循环单选按钮
Cycle radio buttons
我想循环显示 3 个单选按钮(如下所示),每次选择更改之间有 5 秒的延迟。解决这个问题的最佳方法是什么?
我需要这个的原因是因为我使用这些单选按钮作为我的幻灯片导航。
<input type="radio" name="myImages" id="cover1" checked />
<input type="radio" name="myImages" id="cover2" />
<input type="radio" name="myImages" id="cover3" />
如有任何帮助,我们将不胜感激!
这是一个基本示例,说明如何使用 jQuery 执行您的要求:
$(function(){
var id = 1;
window.setInterval(function(){
$( "#cover" + id ).prop( "checked", true );
if (id == 3) {
id = 1;
}
else {
id++;
}
}, 5000);
})
我想循环显示 3 个单选按钮(如下所示),每次选择更改之间有 5 秒的延迟。解决这个问题的最佳方法是什么? 我需要这个的原因是因为我使用这些单选按钮作为我的幻灯片导航。
<input type="radio" name="myImages" id="cover1" checked />
<input type="radio" name="myImages" id="cover2" />
<input type="radio" name="myImages" id="cover3" />
如有任何帮助,我们将不胜感激!
这是一个基本示例,说明如何使用 jQuery 执行您的要求:
$(function(){
var id = 1;
window.setInterval(function(){
$( "#cover" + id ).prop( "checked", true );
if (id == 3) {
id = 1;
}
else {
id++;
}
}, 5000);
})