1<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
2
3// Put this script in the head of your index.html to load jQuery
4// The Google Hosted Libraries is a stable, reliable, high-speed,
5// globally available content distribution network for the most popular,
6// open-source JavaScript libraries.
7
8// Google works directly with the key stakeholders for each library effort
9// and accepts the latest versions as they are released.
1<!-- First either download, or use CDN and reference it -->
2<!-- Here we grab it from a CDN -->
3<script
4 src="https://code.jquery.com/jquery-3.4.1.js"
5 integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
6 crossorigin="anonymous"></script>
7
8<!-- Lets say we have some <p>, with simple text
9 we give it an id -->
10<p id="example">Hello, world</p>
11
12<!-- We shall now play around with this element using jQuery -->
13<script type="text/javascript">
14 // The vanilla way of accessing our example p element is
15 var e = document.getElementById('example');
16 // Then we would faff about with 'e'
17
18 // With jQuery we can get it like...
19 var ej = $('#example');
20
21 // jQuery has its own methods, instead of innerText and
22 // all those similar properties, we can do
23 $('#example').text("Goodbye everybody, I've got to go");
24
25 // Our example p element text will have changed :)
26</script>