*Solved* Pomodoro JS Question on buttons:

//plus / minus buttons
$("#minusA").click(function () {
    $("#minuteA").val(function () {
        return this.value - 1;
    });
});
$("#plusA").click(function () {
    $("#minuteA").val(function () {
        return this.value + 1;
    });
});
$("#minusB").click(function () {
    $("#minuteB").val(function () {
        return this.value - 1;
    });
});
$("#plusB").click(function () {
    $("#minuteB").val(function () {
        return this.value + 1;
    });
});

This is the code for the buttons I have so far. Can someone tell my why this code works for the - buttons but does not for the +?

Hitting - cause the value to go from 25 to 24. Hitting + causes the value to go from 25 to 251.

I think it’s because this.value here is a string, so you get the string '251'. Try using Number(this.value) or +this.value to coerce it to a number.

1 Like

Thank you for the help. I found out why it does that for + and not -.