I want to make my button doing a loop while pressed, and not clicked.
It's not easy to explain but I want to trigger a loop adding 1 to the "Hour" count every quarter of seconds, when the button is pressed continuously, to be faster than pushing 50 time for minutes and seconds. Here is my code :
$('#plus1').mousedown(function() {
setTimeout(function() {
if (parseInt($('#Hours').html()) < 23) {
$('#Hours').html(parseInt($('#Hours').html())+1);
} else {
$('#Hours').html(0);
}
}, 250);
});
Unfortunately when I press the button, it just add 1 and stop even if I push the button. I have no idea what to do, I tried everything. Even putting the timeout function before the mousedown.
If someone can explain how to proceed it'd be kind :3.