我這樣寫怎么不行呢??
//定義"改變顏色"的函數(shù)
function changecolor(ID,COLOR1,COLOR2)
? {document.getElementById("ID").style.color="COLOR1";
? ?document.getElementById("ID").style.backgroundColor="COLOR2";
? }
?<input type="button" value="改變顏色" ?onclick="changecolor(txt,blue,red)">?
2015-05-31
好多錯啊
document.getElementById("ID").style.color="COLOR1";
document.getElementById("ID").style.backgroundColor="COLOR2";
雙引號都去掉
onclick="changecolor(txt,blue,red)"這個函數(shù)執(zhí)行沒有傳ID,而且你的button上也沒有id,blue和red要加引號