jQuery: Set up the source file

This entry is part 2 of 33 in the series jQuery Tutorial

We first look at a simple jQuery program.

To use jQuery, we need to include a source (src) link to a hosted jQuery file.  Source file is usually put in between the <head> tag.

<!DOCTYPE html>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        $(document).ready(function() {
            $('#demo').html('Document is ready and loaded');
<h4 id='demo'>Document Not Ready</h4>

Try The Code

If you visit Google Hosted Libraries, it provides an exact link like:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

To get the latest version, we can always remove the 10.2 from the link:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

This is also an advantage of using hosted code from Google as it provides a simple way to always use the latest jQuery code.

Series Navigation<< jQuery: Introduction
jQuery: Document ready event >>

Leave a comment

Leave a Reply