I'm trying to create an if
and else if
statements using jQuery and I will have two conditions in the if and the else if statements, So I am using &&
as well.
However, every time I use the if
and else if
in my code, my code stops working and I cannot figure out why this is keep happening.
To explain this better, I've created this FIDDLE
The code in question is this:
if ($button.text() == "+" && parseFloat(oldValue) == parseFloat(maximum)) {
alert("You cannot do that");
}else if($button.text() == "+" && parseFloat(oldValue) > parseFloat(maximum)){
.........................
if i change the code above to:
if ($button.text() == "+") {
.........................
everything works fine as it should but with the if and else if statements, nothing seems to work and I don't see any errors in the consul either.
Could someone please advise on this issue?
is there something that I'm missing?
any help would be appreciated.
EDIT:
Based on some of the answers, I've edited my code but I still have a slight issue!
The issue is the number of the input and remaining changes even if the oldValue >= maximum
. This is the FIDDLE