您的位置:首页 > Web前端 > JavaScript

javascript 使用方式

2017-05-30 10:36 253 查看

第一种:内嵌在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>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: