Michael Johnston Michael Johnston - 3 months ago 49
jQuery Question

Cycle radio buttons

I would like to cycle through 3 radio buttons (as seen below) with a 5 second delay between each selection change. Is this possible and if so what is the best way to approach this?
The reason I require this is because I am using these radio buttons as my navigation for a slideshow.

<input type="radio" name="myImages" id="cover1" checked />
<input type="radio" name="myImages" id="cover2" />
<input type="radio" name="myImages" id="cover3" />

Any help would be much appreciated thanks!


Here is a basic example of how to do what you asked with jQuery:

  var id = 1;
    $( "#cover" + id ).prop( "checked", true );

    if (id == 3) {
        id = 1;
    else {
}, 5000);