javascript (四) 改变html样式

 

 

<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)