当尝试在 for 循环中给出高度取决于元素值时不起作用,与背景色相同。如果我通过数组接近项目,它不起作用。元素数据是一个数字。
code:
function chart(){
var divs = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12]
var a1 = document.getElementById("111").style.backgroundColor = "blue" ;
var a2 = document.getElementById("112").style.height = "500px";
var a3 = document.getElementById("113");
var a4 = document.getElementById("114");
var a5 = document.getElementById("115");
var a6 = document.getElementById("116");
var a7 = document.getElementById("117");
var a8 = document.getElementById("118");
var a9 = document.getElementById("119");
var a10 = document.getElementById("120");
var a11 = document.getElementById("121");
var a12 = document.getElementById("122");
var divs = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12]
htmlStr_min_chart = ""
for (let index = 0; index < average_min.length; index++) {
const element = average_min[index];
divs[index].style.height = element*10;
divs[index].style.backgroundColor = "blue"
}
}
chart();
谢谢
qq_遁去的一_1
慕尼黑8549860
相关分类