How to subtract text with jQuery

javascript, jquery

Solution

instead of using

var coluna = $('.coluna').css('width');

(Which returns a string)

use this:

var coluna = $('.coluna').width();

(Which returns an integer)

If you ever find yourself needing to actually split strings, take a look at `substring()`

Problem

How can I subtract text with jQuery? I tried to use minus to delete the text, but it doesn't work. ``` var coluna = $('.coluna').css('width'); ``` In this line, the value outputted is `"300px"`, and I want to remove `"px"` to get just the number `300`.

Original source

Related problems