how to stop time() when mouseout event occur?
`<div id="j" style="height:50px; width:50px; background-color:red;">Hello</div`>
$("#j").mouseenter(function(){
var count = 3;
var counterIncrement=1;
setInterval(timer, 1000);
function timer() {
count = count+counterIncrement;
if (count == 3 ) {
counterIncrement = +counterIncrement;
}
console.log(count);
}
});
i want to reset timer() function when mouseout even occur again mousein then start which count =3