javascript 使用方式
Posted wzjhoutai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 使用方式相关的知识,希望对你有一定的参考价值。
第一种:内嵌在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>
以上是关于javascript 使用方式的主要内容,如果未能解决你的问题,请参考以下文章