javascript实现控制div颜色

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>生成文字</button> <button>blue</button> <button>pink</button> <button>black</button> <div> </div>

以上所述就是本文的全部内容了,希望大家能够喜欢。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgddwy.html