PDA

View Full Version : JS: problema setInterval


Giovanni255
06-11-2015, 15:18
Salve a tutti,
ho messo un range che mi modifica la velocità dello slideshow ma non funziona correttamente. Qualcuno mi potrebbe aiutare gentilmente? Grazie
codice:
<input id="r" type="range" min="500" max="5000" value="500" onchange="change()">

function change(){
var a = parseInt(document.getElementById('r').value);
return a;
}


function img(){
var a = change();
if(document.getElementById('check').checked) {a = 2000;}
$('.slideshow img:gt(0)').hide();
setInterval(function img(){$('.slideshow :first-child').fadeOut().next('img').fadeIn().end().appen dTo('.slideshow')},a);
}

Tuvok-LuR-
06-11-2015, 16:27
probabilmente è perchè non stai cancellando l'intervallo precedente con clearInterval

Giovanni255
06-11-2015, 16:55
Ah ok. Scusa ma dove dovrei mettere quella funzione? Grazie ancora

Giovanni255
07-11-2015, 17:12
Ma dove devo inserire clearinterval?