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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM