A5下载文章资讯

分类分类

javascript实现控制div颜色

2015-07-07 11:05作者:zhao

js控制div颜色

<html>

<head>

</head>

<style>

#div1{width:400px;height:400px;background-color:red;}

</style>

<script>

function blue(){

div1=document.getElementById('div1');

div1.style.backgroundColor='blue';

}

function pink(){

div1=document.getElementById('div1');

div1.style.backgroundColor='pink';

}

function black(){

div1=document.getElementById('div1');

div1.style.backgroundColor='black';

}

</script>

<body>

<button onclick='wr();'>生成文字</button>

<button onclick='blue();'>blue</button>

<button onclick='pink();'>pink</button>

<button onclick='black();'>black</button>

<div id='div1'>

</div>

以上所述就是本文的全部内容了,希望大家能够喜欢。

展开全部

相关

说两句网友评论
    我要跟贴
    取消