0
Getting numeric value of a css property
suppose I have a css property like below, left: 200px; now, how can I get and use the numeric value(200 in this scenario) of this property in jquery. If I write dom_object.css(“left”); it gives me “200px” rather than 200.
2 Respostas
+ 1
You can use parseInt()
Ex.
let padding = parseInt("15px"); //result 15
Taken from : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point.
0
Thank you very much. It worked :-)