Reputation: 345
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
.
Upvotes: 5
Views: 324
Reputation: 4765
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()
Upvotes: 7