このスクリプトを使用して、10までカウントし、0を表示します。
しかし、mouseenterイベントで0から10まで無限にカウントし、mouseleaveイベントで0を表示するにはどうすればよいですか?
$('.div').mouseenter(function() {
var cnt = 0;
var counter = setInterval(function() {
if (cnt < 10) {
$('.count').html(cnt);
cnt++;
}
else {
clearInterval(counter);
$('.count').html("0");
}
}, 1000);
});