如何使用javascript变量使用cssText更改div的高度
您需要字符串连接或。元素也应该是如何使用javascript变量使用cssText更改div的高度,javascript,css,Javascript,Css,您需要字符串连接或。元素也应该是display:block 串联 var randomHeight=Math.floor((Math.random()*100)+50); document.getElementById(“child”).style.cssText=“显示:块;背景色:红色;高度:”+randomHeight+“px;宽度:100px;” ABC var randomHeight = Math.floor((Math.random()*100)+50); document.ge
display:block代码>
串联
var randomHeight=Math.floor((Math.random()*100)+50);
document.getElementById(“child”).style.cssText=“显示:块;背景色:红色;高度:”+randomHeight+“px;宽度:100px;”代码>
ABC
var randomHeight = Math.floor((Math.random()*100)+50);
document.getElementById("child").style.cssText="background-color:red; height:randomHeight+'px'; width:100px;";