在HTML中包含一个外部jQuery文件 [英] Including an external jQuery file in HTML

查看:103
本文介绍了在HTML中包含一个外部jQuery文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,大家,我想我的问题是可以理解的:我想包括一个外部jQuery文件到我的HTML。我尝试了很多方法,我认为(并且认为)是正确的,但它似乎并不如此。



这是我的代码:

 < script type =text / javascriptsrc =js / jquery-1.5.min.js>< / script> ; 
< script type =text / javascriptsrc =js / jquery-ui-1.8.9.js>< / script>
< script type =text / javascriptsrc =js / pinkmoon.js>< / script>

其中pinkmoon.js是保存我的jQuery的文件。

解决方案

如果您导航到实际位于文件夹结构中的页面,如下所示:



http://mywebsite.com/folder1/subfolder1/myPage.html



然后与您目前的代码源代码将如下所示:



src =http://mywebsite.com/folder1/subfolder1/js /pinkmoon.js



这不是你想要的。你需要的是这样的:



< script type =text / javascriptsrc =/ js / pinkmoon.js> < / script>



这会推断出 pinkmoon.js 居住在:



http://mywebsite.com/js/pinkmoon.js


So guys, I guess my question is quite understandable: I want to include an external jQuery file into my HTML. I tried many many ways, which I thought (and still think) were correct, but it doesn't seem to be so.

This is my code:

    <script type="text/javascript" src="js/jquery-1.5.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.9.js"></script>
    <script type="text/javascript" src="js/pinkmoon.js"></script>

Where pinkmoon.js is the file that holds my jQuery.

解决方案

If you navigated to a page that physically resides in a folder structure like so:

http://mywebsite.com/folder1/subfolder1/myPage.html

Then with your current code the source is going to look like this:

src="http://mywebsite.com/folder1/subfolder1/js/pinkmoon.js"

Which is not what you want. What you do want is this:

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

Which would infer that the physical location of pinkmoon.js resides at:

http://mywebsite.com/js/pinkmoon.js

这篇关于在HTML中包含一个外部jQuery文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆