码迷,mamicode.com
首页 > Web开发 > 详细

js控制div颜色

时间:2017-08-19 20:13:51      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:click   ber   body   order   rip   word   cin   table   html   

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

js控制div颜色

标签:click   ber   body   order   rip   word   cin   table   html   

原文地址:http://www.cnblogs.com/kongxc/p/7397436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!