Reputation: 23
Here is my code:
var changeValue = document.getElementById("fontSize");
changeValue.value= 400;
var changeSign = document.getElementById("Box");
changeSign.style.width = ?;
I would like to change the box width based on the "fontSize"
value, in this case 400.
Upvotes: 2
Views: 43
Reputation: 76
I'm assuming that you want to change the box width WHEN the value is changed.
In this case you need an Event:
var changeValue = document.getElementById("fontSize");
changeValue.value= 100;
changeValue.onchange = function(){
var changeSign = document.getElementById("Box");
changeSign.style.width = this.value+'px';
};
<input id='fontSize'>
<div id='Box' style="background-color: red; width: 100px; height: 100px">
You could also:
Upvotes: 0
Reputation: 8355
Is this what you're asking for?
changeSign.style.width = changeValue.value + 'px'
Upvotes: 1