jquery - javascript comparison not working properly? -
The stocktaking is 200 and $ ("#txtqty"). Val () is 5 but it always goes inside the other. Why? I get stockty value from the object and the stockquetty is declared as a global variable and it is used by another function. I tried to output both prices and they are 200 and 5. What is wrong?
If (stocktaxi> 0 & amp; amp; amp; amp; amp; amp; $ ("#txtQty"). Val () = "post-text" itemprop = "text"> String comparison is used only once more than 5 200; And it only happens when both operand string is there, so you should make sure that the values are of the right type before making any comparison:
var inStock = + stockQty, // Probably a string might be called StockRequested = + $ ("#txtqty"). Val (); // Definitely a string if (stockRequested & lt; = inStock) {}
Comments
Post a Comment