js控制div顏色
阿新 • • 發佈:2017-08-19
.get cells light code bsp ner syn con index
<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顏色