Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery value for 'right' on fixed element without 'px'

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');
like image 918
Nick Avatar asked Apr 16 '12 11:04

Nick


1 Answers

parseInt() returns the parsed integer.

var cssValue = $('#id').css('right'); //returns 20px
var parsedCssValue = parseInt(cssValue); //returns 20
like image 69
Paul Avatar answered Oct 19 '22 10:10

Paul