HTML之变色(蓝、绿、红)

来源:互联网 发布:淘宝在哪修改收货地址 编辑:程序博客网 时间:2024/04/27 19:48

  按钮改变颜色:

<!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8">
<title></title>
<script>
function changeColor(str){
var body=document.getElementById("f");
body.style.backgroundColor=str;
}
</script>
</head>
<bodyid="f">
<buttononclick="changeColor('blue')">蓝色</button>
<buttononclick="changeColor('green')">绿色</button>
<buttononclick="changeColor('red')">红色</button>
</body>
</html> 

原创粉丝点击