這應該是這麼簡單,但我正在惡劣的天氣。不能使用javascript更改div區域的背景嗎?
事業部區域載列:
<div class="maincontent">
Stuff in my div
</div>
CSS爲DIV:
.maincontent{
height: 100%;
background-size: 100%;
margin-left:1%;
margin-right:1%;
font-size:16px;
}
然後,我有:
onLoad=changeBackground();
但在此之前,我有以下功能:
function changeBackground(){
document.getElementByAnything('maincontent').style.backgroundColor="yellow";
}
我知道它調用函數,因爲如果我把一個警告框放在那裏顯示。但是,無論getElementBy的組合如何,我都無法對背景進行任何更改?
請幫忙,因爲它的駕駛我瘋了!
TIA
這也需要他將風格從班級改爲ID。 – 2012-02-01 14:52:54