huozhiying

2015.08.11-背景颜色切换函数

简单的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;
}

 

分类:

技术点:

相关文章:

  • 2021-12-19
  • 2021-06-20
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-06
猜你喜欢
  • 2021-12-19
  • 2021-11-29
  • 2021-12-19
  • 2021-05-03
  • 2021-10-19
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案