开发者

Including an external jQuery file in HTML

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


This should work. Be sure to have the file you want to include in a directory called "js" at the same level of you html file.

For exemple :

mysite/index.html
mysite/js/pinkmoon.js
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜