使用HTML一次调用两个javascript文件

Calling two javascript files at once using HTML

本文关键字:两个 javascript 文件 一次 HTML 使用 调用      更新时间:2023-09-26

我有一个html文件和两个。js文件。我把多个脚本标签在一个html文件,因为我使用骨干js。

<html>
   <body>
     <script type="text/x-template" id="my-template">
        some html contents
        <script src="/javascripts/validation.js"></script>
        <script src="/javascripts/other.js"></script>
      </script>
      <script type="text/x-template" id="myfile-template">
        some html contents
      </script>
      <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    </body>
  </html>

我的问题是,我无法从我的模板脚本调用2个js文件。在上面的代码中,只有"validate .js"被调用,如果我把"other.js"放在前面,那么只有"other.js"被调用。

<script src="/javascripts/other.js"></script>
 <script src="/javascripts/validation.js"></script>

有人能帮我吗?

你不能把标签放在其他标签中。

如果你想导入你的两个JS文件,只需这样做:

<!-- Include external JS code -->
<script src="/javascripts/validation.js"></script> 
<script src="/javascripts/other.js"></script> 
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<!-- local JS code -->
<script type="text/x-template" id="my-template">/* some local JS code */</script> 
<script type="text/x-template" id="myfile-template">/* some local JS code */</script>