JQuery - 自动推进 radio 输入 "checked"

标签 jquery css

我想知道是否有人知道如何自动推进 radio 输入?基本上检查一个 radio ,然后每隔一段时间检查下一个 radio ,等等。

这真的让我大吃一惊。这是我到目前为止所拥有的。

$("#image_box > :input:gt(0)").attr("checked",true);
    setInterval(function() {
        $("#image_box > :input:first")
            .next()
            .end()
            .append().attr("checked",true);
        },  3000);

最佳答案

试试这个。每秒它都会检查下一个 radio 。

var $radios = $('input[type=radio]');
$radios.each(function(i, e) {
  setTimeout(function(){
    $(e).prop('checked', true);
  }, 1000 * i);
});

演示: http://jsbin.com/oqubis/1/edit

关于JQuery - 自动推进 radio 输入 "checked",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12419455/

相关文章:

javascript - 无法在 JS 中重置 setInterval

javascript - 32 位或 64 位对 jquery/javascript 有影响吗?

html - 内联 block 元素内的表格破坏了垂直对齐

javascript - 滚动指示器 JavaScript

css - R & Shiny - 边栏文本对齐对齐

javascript - 在 asp.net 中将复选框选定的值插入文本框?

jquery - 使用 jQuery 从 Azure Blob 存储查询 JSON 数据

javascript - 使用Jquery限制浏览器窗口高度不能小于200px?

javascript - 如何获取图像的图像高度以设置另一个div高度

html - 一栏比其他栏大 HTML/CSS