版权声明:本文为博主原创文章,未经博主同意不得转载。

https://blog.csdn.net/qilixiang012/article/details/26688393

第一种:内嵌在html节点中

<html>
<body>

<input type="button" onclick="document.body.style.backgroundColor='lavender';"
value="Change background color" />

</body>
</html>


另外一种:调用方法

<html>
<body>

<script>
function ChangeBackground()
{
document.body.style.backgroundColor="lavender";
}
</script>

<input type="button" onclick="ChangeBackground()"
value="Change background color" />

</body>
</html>

第三种:导入js文件

 <script src=“url” type="text/javascript"></script>


相关文章:

  • 2021-10-06
  • 2021-07-24
  • 2021-09-29
  • 2022-01-11
  • 2021-10-27
  • 2021-08-07
猜你喜欢
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-09-25
  • 2021-10-16
  • 2021-06-05
相关资源
相似解决方案