How to do maths in if and else in jquery? -


hello guys!

i have been trying create if/else statement code in jquery guess if/else statement resting in peace! don't know getting wrong have did , still not working correctly! ok, here problem list ~

  1. my if/else getting inverse!
  2. and think getting messed up!
  3. jslint (in jsfiddle.net) showing no error in jquery code!

please here problem demo link ~~~~~~~~~~

problem demo

here smaple jquery code ~~~~~~~~~

$(function () {    var correct = '10';   var incorrect = '9';    $('div.correct_incorrect').css("background",function () {        if( correct > incorrect )       {          return "#796";       }       else if( correct == incorrect )       {          return "#345";       }       else       {          return "#732";       }    }); }); 

please me out!

thanks in advance

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sorry bother guys previous question solved i'm having new problem code. here i'm trying retrive value 2 input elements! not working.

please have here ----

problem demo 2

thanks in advance (for 1 too!)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the problem correct , incorrect strings. can change them integers fix problem:

                  var correct = 10;                   var incorrect = 9; 

alternatively, can use parseint(mynumasstring, 10) convert string number @ runtime.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -