joe joe - 7 months ago 37
Javascript Question

jQuery/Javascript if css right > go to this css value

Can anyone tell me why the conditional in my code is never true?


It's because I was checking a string against a number and needed to use



You need to parseInt():

$('.zeppelin').css('right') > winWidth

$('.zeppelin').css('right') will return [integer]px. Therefore you are comparing a string type to an integer type.


parseInt($('.zeppelin').css('right')) > winWidth

Also, as a side note, looking through your code, you have:


If you wish to invert an integer, multiply it by -1 instead: