I am trying to repeat an interval on document ready. Interval repeats every 3 seconds but I want it halt it onmousemove event for 5 seconds and then restart interval.
This is my code as far:
$(document).ready(function(){
var myInterval = setInterval(alertMe, 3000);
function alertMe(){
alert('jj');
}
$(document).mousemove(function(event){
// I want delay 5 seconds and then initialize myInterval again
setTimeout(function(){}, 5000);
clearInterval(myInterval);
setInterval(alertMe, 3000);
});
});
Reference Answer 1: JavaScript: How to get setInterval() to start now?
Reference Answer 2: How to wait 5 seconds with jQuery?