0

ex :

 if ( $div.css('marginLeft') == '-2000px') {

 } ..... it is working but i want to check it like

 if ( $div.css('marginLeft') > '-2000px') {

 } ...... Not working
Dave Newton
  • 158,873
  • 26
  • 254
  • 302

1 Answers1

0

The problem is that '-2000px' is a string, and not a number. You cannot use > and < on strings in this way.

Try parsing $div.css as an integer, and writing the pixels as an integer (without the ''):

if ( parseInt( $div.css('marginLeft') ) > -2000 ){
RobertAKARobin
  • 3,933
  • 3
  • 24
  • 46