jQuery is a Javascript library that makes unsing Javascript easier. It's perfect for beginning coders to add some polish to a site, or experienced devs looking to build something quickly. The syntax is approachable, and feels like writing in plain English. jQuery has also been around for a long time, so there's lots of good learning and troubleshooting resources available if you get stuck.
index.html
.
(That's this page!)
script.js
to see how we use jQuery to listen for
event, then find and modify dom elements in the HTML.
jQuery has lots of ways that you can add interactions to the page. One of the most common ways is by using event handlers. This means that the script file waits for a user to complete an action, then fires the function.
This box is listening for a mouseover. When you mouseover it, something fun happens....
This button is listening for a click. When you click it, the text next to it will tell you how many times its been clicked
Button has been clicked 0 timesThere are lots more event handlers you should explore on your own! At the bottom of each page there are also demos where you can see how the code works
index.html
.To use jQuery you need to add it to your page. It's available in two different ways: as a CDN you link to, as well as a file that you can download.
This starter app has jQuery imported from a CDN.