I’m working on my pomodoro timer. I have two buttons. #tplus (below) that adds minutes to the timer, and the #minus button with opposite functionality. I want them, when .mousedown, to add/subtract minutes from the timer quicker, so the user doesn’t have to click so many times, when changing the value.
In my head i thought this would work:
// $('#plus').click(function (){plusOne();}); // end plus
// I commented out the line at the top, to try it with mousedown.
// That line would add one minute per click.
$('#plus').mousedown(function() {
var quickAdd = setInterval(plusOne(), 300);
}).mouseUp(function() {
clearInterval(quickAdd);
});
The code you helped me with worked, but I wanted to something more complicated - i wanted for adding/subtracting values to add/subtract quicker if the click is held longer.
So i thought i put setTimeout() in setInterval(). But of course it didn’t work. It’s possibly something with the scope. I wasn’t able to find an answer on stackoverflow though
Your code should be working, it is basically the same code as I wrote. It was early in the morning and I was too lazy to look for the exact error, so I just wrote my version
Now that you asked, I took a look and found the error in your code - it’s on line 4 See if you can spot it (this kind of errors is why I stopped using codepen).