完整js代碼//改變行間樣式函數(shù)functionchangeStyle(elem,name,value){elem.style[name]=value;//為什么不能寫(xiě)成elem.style.name=value}//執(zhí)行改變屬性函數(shù)window.onload=function(){varoSubmitBtn=document.getElementById("submit");varoResetBtn=document.getElementById("reset");varoInput=document.getElementsByTagName("input");varoDiv=document.getElementById("div1");oSubmitBtn.onclick=function(){changeStyle(oDiv,oInput[0].value,oInput[1].value);}oResetBtn.onclick=function(){oDiv.removeAttribute("style");}}問(wèn)題是第一個(gè)函數(shù)內(nèi)部如果改成elem.style.name=value就不行了,求解
關(guān)于改變行間樣式函數(shù)的寫(xiě)法
蝴蝶刀刀
2019-04-10 20:48:52