I would need to divide a value given by .style.width function in Javascript. My code looks like this:
var x = document.getElementsByClassName("item");
var i;
var v = x[0].style.width;
In variable 'v' I have some value in pixels, e.g. 200px width.
I would need to divide this value by 2 to get 100px.
But this formula doesn't work:
var v = x[0].style.width / 2;
What am I doing wrong? Thanks for help.
var v = parseInt(x[0].style.width) / 2;var v = x[0].clientWidth / 2 + "px";