6

There are a few similar titles to this (for example, here, here and here), but I refuse to believe it's as complicated as they seem to indicate. The following gives the value '20px'. How can I get it to just return '20'?

var base=$('#id').css('right');
Community
  • 1
  • 1
Nick
  • 5,995
  • 12
  • 54
  • 78

1 Answers1

22

parseInt() returns the parsed integer.

var cssValue = $('#id').css('right'); //returns 20px
var parsedCssValue = parseInt(cssValue); //returns 20
Aaron Chambers
  • 1,354
  • 2
  • 12
  • 27
Paul
  • 8,974
  • 3
  • 28
  • 48