var radiobuttons = $('input[name="slider"]');
radiobuttons.eq(0).prop( "checked", true );
var defalutvar = 0;
function ani(a) {
function animate() {
var currentbutton = radiobuttons.eq(a);
currentbutton.prop( "checked", true );
a = (a + 1) % radiobuttons.length; //0, then 1, then 2, then 0, then 1, then 2, then 0, ...
}
var rollDemRadios = setInterval(animate,1000);
}
$( document ).ready(ani(defalutvar));
$('#active label').click(function () {
clearInterval(rollDemRadios);
});
This is my code. I created a function ani to set a starting variable for a loop.
Now i can't stop setInterval. Someone can help me?
Update:
var radiobuttons = $('input[name="slider"]');
radiobuttons.eq(0).prop( "checked", true );
var defalutvar = 0;
var negative = -1;
function ani(a) {
function animate() {
var currentbutton = radiobuttons.eq(a);
currentbutton.prop( "checked", true );
a = (a + 1) % radiobuttons.length; //0, then 1, then 2, then 0, then 1, then 2, then 0, ...
}
var rollDemRadios = setInterval(animate,1000);
$('#active label').click(function () {
clearInterval(rollDemRadios);
});
}
ani(0);
$('#active label').click(function () {
i = $('input[name="slider"]:checked').index();
ani(i);
});
Sorry. I will say clearly my idea. I am coding an java-based autoplay for a css-only slider. It will autoplay first then when I click a node it would stop and refresh with a new starting variable. My code is not working correctly, it continuouses at old position that it was running. It is my real problem. Sorry all.