如何使用Javascript更改背景颜色?

use*_*606 0 html javascript css

我想使用用户输入更改页面的背景颜色.到目前为止这是我的代码..

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script type = "text/javascript">
function paintIt(){
    color = prompt("Enter the color you want on the Background???");
    switch (color){
    }
}
</script>
<form>
<input type = "button" value = "Paint Me" onclick ="paintIt()">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

而我的简单css

   html {font-family:Arial, Helvetica, sans-serif; colour:#fff;}
            body{background-color:#ccc; margin:0;}
Run Code Online (Sandbox Code Playgroud)

谢谢

Han*_*año 5

function paintIt()
{
    color = prompt("Enter the color you want on the Background???");
    document.body.style.backgroundColor = color;
}
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/5H8ux/

尝试像#000000#fff.