user3259282 user3259282 - 4 months ago 8
Javascript Question

Input box to change the background color of a webpage using javascript

On my web page I have JavaScript script that changes the background color. My HTML is:

<a href="#" onclick="javascript:changeBGC('#FFFFFF')">White</a>

My Javascript function is:

function changeBGC(color){
document.bgColor = (color);

How can I change the color of the background getting the color from an
box instead of putting a predefined value?


Here's a FIDDLE

<input id="color" type="text" onKeyUp="color();">

function color() {'color').value;