当css放在html外部时代码如上 当css在html内部时,只需要var div1=document.getElementById(div1"); div1.style.backgroundColor="黑色"; 即可实现更改样式