Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

JQuery - auto advancing radios inputs "checked"

JQuery - auto advancing radios inputs "checked"

Problem

I was wondering if anyone new how to auto advance radio inputs? basically have one radio checked, then check the next one in an interval etc.

This has been really kicking my butt. Here is what I have so far.

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

Solution

Try this. Every second it will check the next radio.

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

Demo: http://jsbin.com/oqubis/1/edit

Solution courtesy of: elclanrs

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

JQuery - auto advancing radios inputs "checked"

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×