<!--出现在script标签内部的代码将依次执行-->
<html>
<head>
<script>
alert("The first script is in the head!");
</script>
<script src=out.js></script>
<script defer>alert("delay script in the head!");</script>
<!--defer描述的将推迟到页面加载完成后执行-->
</head>
<body>
<script>
alert("The second script is in the body!");
</script>
<script src=out.js></script>
<!--引用外部源文件-->
<input type="button" value="button1" οnclick='alert("button1 is clicked!")'/>
<!--所有的事件都以on开头-->
</body>
</html>
<!--还可以在地址栏中输入JavaScript代码,javascript:alert("script in the url!");-->
html调用JavaScript的方式
最新推荐文章于 2024-06-10 20:53:57 发布