码迷,mamicode.com
首页 > 其他好文 > 详细

2015.08.11-背景颜色切换函数

时间:2015-08-11 13:58:02      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:

简单的demo,点击切换背景颜色切换,附上代码。


.html文件

<div> class=‘red‘ id="box">美美哒!...........</div>

.css文件

.red{
   width:100px;
   height:100px;
   background-color:red;
   border-radius:0 70px 0 60px ;
   transition-duration:1s;
}
.yellow{
 width:150px;
 height:150px;
 border-radius:80px 0 100px 0;
 transition-duration:1s;
 background-color:yellow;
}

 

.js文件

window.onload = function(){
  var box = document.getElementById(‘box‘);
  box.onclick = toYellow;
};

function toRed(){
   this.className =‘red‘;
   this.onclick = toYellow;
}

function toYellow(){
  this.className =‘yellow‘;
  this.onclick = toRed;
}

 

2015.08.11-背景颜色切换函数

标签:

原文地址:http://www.cnblogs.com/huozhiying/p/4720632.html

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