<h1 id="domo"> this is testing test</h1>
<script>
function changecolor(){
element=document.ElementByID("domo");
element.style.color="#ff0000";
}
</script>
<button type="button" onclick="changecolor()">点击我</button>
说明:
按钮点击事件触发函数changecolor给id为domo的元素加上style=”color:#ff0000“ ,也可直接在<h1 style="color:#ff0000">
javascript (四) 改变html样式,布布扣,bubuko.com
原文:http://www.cnblogs.com/bokun-wang/p/3654535.html