HTML 引入 JS 文件

总结下,常用的一下几种方式引入 js 代码:

1、页头引入(head 标签内);

2、页中引入(body 标签内);

3、引入外部 JS 文件;

一、页头引入 JS

<!DOCTYPE html>
<html>

<head>
    <title></title>
    <script type="text/javascript">
         //这里编写JavaScript程序
    </script>
</head>

<body>
</body>

</html>

二、页中引入 JS

<!DOCTYPE html>
<html>

<head>
    <title></title>
</head>

<body>
    <script type="text/javascript">
          //这里编写JavaScript程序
    </script>
</body>

</html>

三、引入外部 JS 文件

<script src="js/index.js" type="text/javascript"></script>

猜你喜欢

转载自blog.csdn.net/weixin_46774901/article/details/129822732