Reputation: 317
Hey, i cant seem to get this to work, im a little confused on how im supposed to pass the colour paramaters:
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)'>
Upvotes: 0
Views: 204
Reputation: 7671
I'm guessing this should do the trick
function colourGreen(red, green, blue)
{
document.getElementById("button1").style.backgroundColor = 'rgb('+red+','+green+','+blue')';
}
Upvotes: 3
Reputation: 40789
.style.backgroundColor = 'rgb(' + red +', ' + green + ', ' + blue ')';
Upvotes: 1