javascript实现控制div颜色
js控制div颜色
<html>
<head>
</head>
<style>
#div1{width:400px;height:400px;background-color:red;}
</style>
<script>
functionblue(){
div1=document.getElementById('div1');
div1.style.backgroundColor='blue';
}
functionpink(){
div1=document.getElementById('div1');
div1.style.backgroundColor='pink';
}
functionblack(){
div1=document.getElementById('div1');
div1.style.backgroundColor='black';
}
</script>
<body>
<buttononclick='wr();'>生成文字</button>
<buttononclick='blue();'>blue</button>
<buttononclick='pink();'>pink</button>
<buttononclick='black();'>black</button>
<divid='div1'>
</div>
以上所述就是本文的全部内容了,希望大家能够喜欢。