我需要从变量中获取值,并将set设置为字符串

时间:2018-04-11 05:12:45

标签: javascript

var number = +document.getElementById("tall1").value;
document.getElementById("knapp").onclick = doSomething;

function doSomething(){
    var color = document.getElementById("graf1");
    farge.style.height = number + "px";}

如何从var编号中获取值并将其设置为高度?

1 个答案:

答案 0 :(得分:0)

我认为您应该重新订购代码。

document.getElementById("knapp").onclick = doSomething;

function doSomething(){
    var number = +document.getElementById("tall1").value;
    var color = document.getElementById("graf1");
    farge.style.height = number + "px";
}