I am trying to change a the width value of my div using javascript. Using:
document.getElementById("id").style.width = "25%";
works fine for string literals, but I want to set the value using a variable.
I am trying to change a the width value of my div using javascript. Using:
document.getElementById("id").style.width = "25%";
works fine for string literals, but I want to set the value using a variable.
When concatenating strings and variables javascript will use their string representation, try the following:
var variable = 25;
document.getElementById("id").style.width = variable + "%";