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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -