In order to use jQuery, do I have to use the following reference in my html?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
What if my server does not have an internet connection?
Step 1: Firstly, we have to open that Html file in which we want to add the jQuery using CDN. Step 2: After then, we have to place the cursor between the head tag just before the title tag. And, then we have to use the <script> tag, which specify the src attribute for adding.
You can write it directly to the HTML doc inside <script> tags or link with <script src="javascript. js"></script> .
jQuery is a JavaScript file that you will link to in your HTML.
The purpose of jQuery is to make it much easier to use JavaScript on your website. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
Use this code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">window.jQuery || document.write('<script src="/res/jQuery/jquery-1.7.1.min.js"> \x3C/script>');</script>
This will try to download from the CDN, or otherwise use the local one. You must download the local one first though.
It will not work if you don't have internet connection.
To work locally you should copy jquery.js
to your local directory and give relative path.
<script src="/jquery/1.5/jquery.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With