I want to pass a variable in a function inside setInterval, i'm tried with this code but doesn't work.
Anyway function orologio(arg) append in a div a variable returned by other function orario_sisma where the second argument (formato_orologio) is passed in function orologio.
With clickevent i must to stop the first setInterval and run it another time but with new argument.
How can i do this?
var orologio_real= setInterval(orologio(1), 1000);
$('#A').on('click', function(){
clearInterval(orologio_real);
orologio_real= setInterval(orologio(0), 1000);
});
function orologio (formato_orologio){
$('#remove').remove();
var milliseconds= new Date();
milliseconds= milliseconds.getTime();
var real_time= orario_sisma(milliseconds, formato_orologio);
real_time= '<div id="remove">'+real_time+'</div>';
$(real_time).appendTo('#data-real-time');
}
Thanks a lot and sorry for my english.