Getting started with jQuery (tutorial) - Beau teaches JavaScript

freeCodeCamp.org · Beginner ·🌐 Frontend Engineering ·9y ago

Key Takeaways

The video tutorial introduces jQuery, a lightweight JavaScript library, and covers its basic syntax, including selectors, actions, and events, with examples of DOM manipulation and AJAX calls.

Full Transcript

jQuery is a very popular lightweight JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on websites. jQuery simplifies a lot of the complicated things from JavaScript like Ajax calls and DOM manipulation. To use it, you can either download it and host it yourself or you can just link to a CDN. A lot of people just use a CDN. So, to do that, you just go into HTML file and put this line. So, right within the head tag, you can see we have the head tag here and inside that you're going to put this line script and the source equals and then you just link to the jQuery here, the jQuery CDN. If you can't remember what that is, you can just go to Google and type in jQuery CDN and you can also download it from jquery.com. And if you are creating something on CodePen like I am right now, there is an even easier way to add jQuery. You just go to settings and then on the JavaScript tab, quick add, you go down to jQuery and then you just click save and close and then you you don't even have to put the script here. It adds it for you. So, down the JavaScript code here, I'm going to show you the basic syntax of jQuery. You're always going to start with the a dollar sign and then in parentheses you're going to put a selector. Now, this selector can be any CSS selector. And then you're going to put dot and then you're going to put the action. So, whatever action you're going to have jQuery perform with that CSS selector. So, I'm going to get rid of this. I'm just about to copy and paste some code that has three jQuery commands and what we're going to talk about those. Okay, so here are three jQuery commands. So, this first jQuery command is is kind of special. Uh you're usually going to want to put your entire code in a document.ready event. So, document.ready just means when the document is ready or when the document is completely loaded, then you're going to run the rest of your code. If you don't put your code in a document.ready event, your code may try to access an element from the HTML that has not yet loaded. So, this just selects the document and when it's ready, it runs this code. So, now let's look at the code inside the document.ready event. Again, we start with the dollar sign and then we have a CSS selector, button is just going to select the the button tag right here. And then we're going to add a click action or a click event. So, this is going to be the action click and when the button is clicked, we're going to run the command that's inside that. So, inside we have another jQuery command. You know it's jQuery cuz it starts with a dollar sign and then we're going to select the P tags and we're going to hide them. So, there's two P tags here. You can see these two right here. So, if I click the bell button, the P tags are hidden. I'm just going to reset that and we're going to change the code a little bit. So, I'm just going to change this one right here. I'm going to change this to serial with the hash sign or the pound sign right before this. That's just the CSS selector for ID. So, you can see up here, ID of serial. So, now it's going to select this whole thing right here. So, if we run that and then we click the button, it just hid the paragraph element with the ID of serial. And you can see these two lines, one of them is a has a paragraph tag, one of them has a div tag, but they both have the same class of unicycle. So, if we just use the CSS dot unicycle, that's how you would show a class, the dot. If I click the button, it hides everything that's unicycle. Now, let me show you one more way you can mix this up. Um here, we've been selecting the button to add the click event, but we can also make this H3. So, we can we can really add the click event to anything. And now we're going to hide the button. So, let's see what happens there. When I click the button now, nothing happens. But if I click the heading, the button disappears. Okay, that's just a quick introduction to jQuery. I'm going to be going over more information about jQuery in future videos. Thanks for watching. My name is Beau Carnes. Don't forget to subscribe, and remember, use your code for good.

Original Description

jQuery is a very popular, lightweight JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on websites. jQuery simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation. Learn the basic syntax in this video. 💻 Code: https://codepen.io/beaucarnes/pen/mwGZre?editors=1010 🐦 Beau Carnes on Twitter: https://twitter.com/carnesbeau ⭐JavaScript Tutorials Playlists⭐ ▶JavaScript Basics: https://www.youtube.com/playlist?list=PLWKjhJtqVAbk2qRZtWSzCIN38JC_NdhW5 ▶Data Structures and Algorithms: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkso-IbgiiP48n-O-JQA9PJ ▶ES6: https://www.youtube.com/playlist?list=PLWKjhJtqVAbljtmmeS0c-CEl2LdE-eR_F ▶Clean Code: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkK24EaPurzMq0-kw5U9pJh - Learn to code for free and get a developer job: https://www.freecodecamp.com Read hundreds of articles on technology: https://medium.freecodecamp.com And subscribe for new programming videos every day: https://youtube.com/subscription_center?add_user=freecodecamp ❤️ Support for this channel comes from our friends at Scrimba – the coding platform that's reinvented interactive learning: https://scrimba.com/freecodecamp
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from freeCodeCamp.org · freeCodeCamp.org · 39 of 60

1 React: Production Server Setup Part 2 - Live Coding with Jesse
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
2 cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
3 Browser history tutorial - Beau teaches JavaScript
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
4 Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
5 React: Parameterized Routing with Next.js - Live Coding with Jesse
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
6 React: Dealing with jQuery Issues - Live Coding with Jesse
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
7 setInterval and setTimeout: timing events - Beau teaches JavaScript
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
8 Browser and Device Testing - Live Coding with Jesse
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
9 Last Minute Updates - Live Coding with Jesse
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
10 Post Launch Updates - Live Coding with Jesse
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
11 React: Setting Up Google Analytics - Live Coding with Jesse
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
12 React: Masonry Layout - Live Coding with Jesse
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
13 Load Balancing Digital Ocean Droplets - Live Coding with Jesse
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
14 try, catch, finally, throw - error handling in JavaScript
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
15 Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
16 Graphs: breadth-first search - Beau teaches JavaScript
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
17 React: Masonry Layout Part 2 - Live Coding with Jesse
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
18 React: WordPress API Live Search - Live Coding with Jesse
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
19 Creating WordPress Custom Post Types - Live Coding With Jesse
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
20 Dates - Beau teaches JavaScript
Dates - Beau teaches JavaScript
freeCodeCamp.org
21 Miscellaneous Front End Updates - Live Coding with Jesse
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
22 Merging a Pull Request from GitHub - Live Coding with Jesse
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
23 React + Prettier + Standard JS - Live Coding with Jesse
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
24 React: Sortable Responsive Table - Live Coding with Jesse
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
25 Geolocation Sorting by Distance - Live Coding with Jesse
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
26 Tradeoff Matrix - Agile Software Development
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
27 The Definition of Ready - Agile Software Development
The Definition of Ready - Agile Software Development
freeCodeCamp.org
28 Getting first React job without experience - Ask Preethi
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
29 React: Google Analytics Click Tracking - Live Coding with Jesse
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
30 Submitting a PR to an Open Source Project - Live Coding with Jesse
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
31 Should I go back to school to get CS degree? - Ask Preethi
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
32 Hero Section CSS Changes - Live Coding with Jesse
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
33 Working Agreement - Agile Software Development
Working Agreement - Agile Software Development
freeCodeCamp.org
34 A day at Pennybox with Co-Founder Reji Eapen
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
35 React: Sorting and Filtering Data - Live Coding with Jesse
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
36 React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
37 React: Building a New UI - Live Coding with Jesse
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
38 Definition of Done - Agile Software Development
Definition of Done - Agile Software Development
freeCodeCamp.org
Getting started with jQuery (tutorial) - Beau teaches JavaScript
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
40 Making a React Blog with WordPress Content - Live Coding with Jesse
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
41 React, NextJS, CSS - Live Coding with Jesse
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
42 jQuery events - Beau teaches JavaScript
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
43 React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
44 React: Working with API Data - Live Coding with Jesse
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
45 React: Refactoring Components - Live Streaming with Jesse
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
46 jQuery effects - Beau teaches JavaScript
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
47 More React Refactoring - Live Coding with Jesse
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
48 animate in jQuery - Beau teaches JavaScript
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
49 "Finishing" My React Site - Live Coding with Jesse
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
50 Starting a New React Project (P2D1) - Live Coding with Jesse
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
51 React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
52 The Agile Manifesto - Agile Software Development
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
53 jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
54 React Project 2 Day 3 - Live Coding with Jesse
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
55 The INVEST approach to product backlog items
The INVEST approach to product backlog items
freeCodeCamp.org
56 React Project 2 Day 4 - Live Coding with Jesse
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
57 Chickens and Pigs - Agile Software Development
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
58 React Project 2 Day 5 - Live Coding with Jesse
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
59 jQuery: add and remove DOM elements - Beau teaches JavaScript
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
60 React Project 2 Day 6 - Live Coding with Jesse
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org

This video tutorial introduces jQuery and covers its basic syntax, including selectors, actions, and events, with examples of DOM manipulation and AJAX calls. It provides a foundation for using jQuery in web development projects.

Key Takeaways
  1. Include jQuery in an HTML file using a CDN or by downloading it
  2. Use the document.ready event to ensure the DOM is loaded before running jQuery code
  3. Select elements using CSS selectors and perform actions on them
  4. Add event handlers, such as click events, to elements
  5. Use jQuery to manipulate the DOM and perform AJAX calls
💡 jQuery simplifies DOM manipulation and event handling, making it easier to use JavaScript on websites.

Related Reads

Up next
Refactor HTML5 Canvas
Stephen Blum
Watch →