小编use*_*606的帖子

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

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

<!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)

谢谢

html javascript css

0
推荐指数
1
解决办法
2万
查看次数

标签 统计

css ×1

html ×1

javascript ×1