来源:https://www.w3school.com.cn/js/js_htmldom_css.asp

1,

document.getElementById(id).style.property = new style

  

<html>
<body>

<p >Hello World!</p>

<script>
document.getElementById("p2").style.color = "blue";
</script>

<p>上面的段落已被脚本改变。</p>

</body>
</html>

  

 

相关文章:

  • 2022-12-23
  • 2021-12-04
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
猜你喜欢
  • 2021-08-05
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-12-19
相关资源
相似解决方案