嘿,我似乎无法让这个工作,我对如何通过颜色参数有点困惑:
function colourGreen(red, green, blue)
{
document.getElementById("button1").style.backgroundColor = 'rgb(red,green,blue)';
}
............. .............
<input type="button" id = "button2" value="Price up" onclick = 'colourGreen(0,255,0)'>
答案 0 :(得分:3)
我猜这应该做的伎俩
function colourGreen(red, green, blue)
{
document.getElementById("button1").style.backgroundColor = 'rgb('+red+','+green+','+blue')';
}
答案 1 :(得分:1)
...'rgb('+red+','+green+','+blue+')';
答案 2 :(得分:1)
.style.backgroundColor = 'rgb(' + red +', ' + green + ', ' + blue ')';