<!DOCTYPE HTML><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>DIV變色練習(xí)</title> <style type="text/css"> div { margin:0 auto; ? ?width:600px; height:200px; background-color:yellow; } p { text-align:center; } </style></head><body> <div id="div-one" ></div> <p> <button type="button" onclick="objDiv()">點(diǎn)我</button> </p> <script> function objDiv(){ a=document.getElementById("div-one"); a.style.background="green" } </script></body></html>
怎么才能通過(guò)點(diǎn)按鈕來(lái)回切換DIV的背景色呢?
0_夢(mèng)醒無(wú)痕_0
2016-03-09 22:56:21