How can i active/fire/trigger the setInterval with a button? and if the button is not clicked how to make it auto fire on 3 second, but if i click on the button it fire it on 0.1
second and restart evrything. please help me out guys
$('button').click(function(){
setInterval(function(){
updateStats("updateStats");
}, 100);
});
else
setInterval(function(){
updateStats("updateStats");
}, 3000);
Edit
Only everytime the button is clicked 100ms, if not clicked then it most do it auto on 3000ms, unless you click it ofc
Part :
function updateStats(stat)
{
var stat = ["GAME","USERS"];
var url = "NET.php";
$.each(stat, function(i, key){
$.post(url, {stats: key}, function(data) { // stats to stat
$("#" + key).html(data);
$('.s').emoticonize({
//delay: 800,
//animate: false
});
});
});
}
This will fire after 3000 if you clicked the button it will fire after 100
UPDATE upon your request