JS 修改元素

var ele;
window.onload=function(){
    ele=document.createElement('div');
    ele.id='myEle1';
    ele.style.border='1px solid black';
    ele.style.height='20px';
    container=document.querySelector(".container");
    container.appendChild(ele);
    console.log(ele.style.height);
    setInterval(changeDIV,100);
}

function changeDIV(){
    //直接修改全局变量即可  //无需再querySelector一次
    ele.style.height= (parseInt(ele.style.height)+1)+'px';
}
原文地址:https://www.cnblogs.com/cart55free99/p/3749999.html