I am wondering how to reference jquery
in html
.
To my understanding there has to be 2 links:
here is my reference that does not seem to work..
<script type="text/javascript" src="jquery.js" ></script>
<script src="jquery-2.1.3.js"></script>
ps. 1st time here, I know the question sounds stupid, I'm just going crazy with that
You only need one reference. Let's say your folder structure is like this:
my_project/
index.html
jquery.js
Then in your index.html you just need to do this:
<script type="text/javascript" src="jquery.js" ></script>
To include the JS file. If however you don't have jquery.js there, and you want to reference it from a CDN (content delivery network). You could do something like this:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" ></script>
It's good practice to use a CDN, or content delivery network, as the host for jQuery and other similar libraries. This article does a good job of explaining the benefits. One example of a quality, free CDN is Google . Here's how you would include Google's version of jQuery 2.1.3:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
link from file
<script type="text/javascript" src="js/jquery.js"></script>
link from source
<script type="text/javascript" src="http://thesource.com/jquery.js"></script>
internal script
<script> // javascript here </script>
1 to the library: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
2 to the external js file: <script type="text/javascript" src="/js/pinkmoon.js"></script>
, assuming that js file is in the same folder as index.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.