Code Editor
Web Browser
Learn
jQuery Setup

Adding jQuery

To include jQuery, we use a <script> tag as follows:

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>

In this example, the jQuery library is loaded from the jQuery content delivery network (CDN). A CDN is a collection of servers that can deliver content.

You must include the <script> tag in the HTML document before you link to a JavaScript file that uses the jQuery library. The integrity and crossorigin properties in the example ensure the file is delivered without any third-party manipulation.

We will use jQuery methods in a JavaScript file called main.js, which we will load into index.html using a <script> tag. We need to load the jQuery library before the main.js file. Otherwise, the computer will not understand the jQuery used in main.js.

Report a Bug
If you see a bug or any other issue with this page, please report it here.