[Solved] jquery mistake to compare two variables


Your code doesn’t replicate the problem. You should always test your SSCCE‘s to make sure they actually demonstrate the problem. It makes it much easier for people to help you and you even have a good chance of solving the problem yourself while making the SSCCE work.

You seem to be comparing strings instead of numbers, so they are being compared lexicographically, and of course '100' < '20' lexicographically, since '1' < '2'.

You should use parseInt to convert your strings to numbers:

var c="100";
c = parseInt(c, 10); // Convert `c` to number

solved jquery mistake to compare two variables