包括外部js文件

时间:2017-10-18 09:28:42

标签: javascript jquery

我正在尝试使用jQuery和Sweetalert的脚本,它工作正常,直到我将自定义js移动到单独的文件中,然后停止工作,另外控制台显示虽然我已经在head标签中加载了所有内容,但只有jquery出现在那里,其他两个文件显示为在body标签中?

<head>
    <title>Inserting, copying and removing elements</title>
    <link rel="stylesheet" href="css/styles.css" />
    <!-- include jQuery-->
    <script src="js/jquery.js"></script>
    //Include sweetalert//
    <script src="js/sweetalert.min.js"></script>
    <!-- include custom js -->
    <script src="js/custom.js"></script>
    </head>

1 个答案:

答案 0 :(得分:0)

第二条评论的评论语法错误,导致在<head>标记内写入纯文字,将<head>的其余部分放入正文。

只需像其他人一样编辑您的第二条评论:

<head>
  <title>Inserting, copying and removing elements</title>
  <link rel="stylesheet" href="css/styles.css" />
  <!-- include jQuery-->
  <script src="js/jquery.js"></script>
  <!-- include sweetalert-->
  <script src="js/sweetalert.min.js"></script>
  <!-- include custom js -->
  <script src="js/custom.js"></script>
</head>