Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Selecting elements to use


From:

jQuery for Web Designers

with Joe Chellman

Video: Selecting elements to use

Better than 99% of the time when you're working with jQuery, you're going to start out by selecting some elements from your document. And then, doing some manipulations on them. And jQuery has a very, very rich set of tools for getting those elements. We're going to look at some of those, in this movie. So here on my Build a Bouquet page, I'm going to open up my Web Inspector, specifically my JavaScript console, so I can execute some jQuery and we can see the results immediately without having to reload the page and whatnot. So jQuery is encapsulated in the dollar sign function, you could also use jQuery spelled out like this, we are going to use a dollar sign.
Expand all | Collapse all
  1. 2m 17s
    1. Welcome
      1m 4s
    2. What you should know
      37s
    3. Using the exercise files
      36s
  2. 11m 59s
    1. jQuery is a JavaScript library?
      1m 15s
    2. When to use jQuery
      2m 51s
    3. Alternatives to jQuery
      1m 24s
    4. Which version of jQuery to use
      1m 50s
    5. How to install jQuery
      3m 21s
    6. Reference materials
      1m 18s
  3. 19m 19s
    1. Getting ready
      2m 26s
    2. Selecting elements to use
      3m 54s
    3. Performing multiple operations on the same line with chaining
      2m 30s
    4. Using classes to find what you're looking for
      3m 52s
    5. Adding, modifying, and removing content dynamically
      4m 3s
    6. Challenge: Form feedback
      1m 12s
    7. Solution: Form feedback
      1m 22s
  4. 18m 28s
    1. Triggering a change based on activity with event binding
      4m 37s
    2. Reading and changing values
      4m 17s
    3. Working with HTML attributes
      4m 55s
    4. Challenge: Dynamic contact form
      1m 27s
    5. Solution: Dynamic contact form
      3m 12s
  5. 16m 42s
    1. Using the Colorbox plugin to build a slideshow gallery
      4m 22s
    2. Implementing Colorbox on your site
      2m 46s
    3. Changing Colorbox options
      5m 53s
    4. Challenge: Convert to a slideshow
      1m 6s
    5. Solution: Convert to a slideshow
      2m 35s
  6. 28m 37s
    1. Using jQuery or CSS to animate elements
      2m 24s
    2. Creating simple jQuery animations
      4m 35s
    3. Animating numeric properties with animate()
      4m 56s
    4. Understanding animation easing
      4m 4s
    5. Putting it together: Flowers in the cart
      6m 4s
    6. Callbacks: What to do when the animation ends
      3m 27s
    7. Challenge: Improve the animation
      1m 3s
    8. Solution: Improve the animation
      2m 4s
  7. 4m 45s
    1. More fun plugins
      2m 38s
    2. What's next: More jQuery
      50s
    3. What's next: More JavaScript
      1m 17s

please wait ...
Watch the Online Video Course jQuery for Web Designers
1h 42m Intermediate Oct 31, 2013

Viewers: in countries Watching now:

Take the next step in your web design career with jQuery, which amplifies JavaScript's power and puts a library of prebuilt functions and a diverse selection of plugins at web designers' fingertips. This course explains what jQuery is, how to install it, and use it to script more interesting, interactive websites. Author Joe Chellman will show you how to use jQuery to add web form usability, audio and video, animation, and other features like slideshow galleries to your existing HTML and CSS-based webpages.

Check out JavaScript for Web Designers for more detailed instruction on JavaScript.

Topics include:
  • What is jQuery?
  • Installing jQuery
  • Performing multiple operations with chaining
  • Using classes
  • Adding, modifying, and removing content dynamically
  • Triggering a change with event binding
  • Creating a dynamic contact form
  • Building a slideshow gallery
  • Creating simple jQuery animations
Subject:
Web
Software:
jQuery
Author:
Joe Chellman

Selecting elements to use

Better than 99% of the time when you're working with jQuery, you're going to start out by selecting some elements from your document. And then, doing some manipulations on them. And jQuery has a very, very rich set of tools for getting those elements. We're going to look at some of those, in this movie. So here on my Build a Bouquet page, I'm going to open up my Web Inspector, specifically my JavaScript console, so I can execute some jQuery and we can see the results immediately without having to reload the page and whatnot. So jQuery is encapsulated in the dollar sign function, you could also use jQuery spelled out like this, we are going to use a dollar sign.

So if I want to select an element by its ID, I just spell it out just like in CSS. So let's say I want to select the header and here in the console I get the result back so I know that there is in fact something there. If I want to select something by class, again it's just like in CSS. So let's look for the inline block class. And there's a couple of things with that on this page. Basically anything you can think of that works in CSS will work here. I can also do tags like this, find all my H3 tags, all of them on the entire page. I can do attributes selectors, so let's say I want to find everything on the page that has a role which is banner, great there's one of those.

If I change this to something that doesn't exist like say banner one, I get back an empty array. jQuery always returns an array like object of whatever it finds, which means that you can test the length of it the way you would normally in Java Script. So if you ever need to find out how many of something you found you can check the length property and that will give you the right answer. And of course I can combine selectors just like I do in CSS. So I can say, let's look for all unordered lists that are children of a list item. We have many of those. And incidentally of course in the Web Inspector you can expand these to see what all is inside those results that you got back.

Now, of course, there are different ways that you could start to get into this sort of thing. You could go crazy. You know, give me everything that's a descendant, and you know, all kinds of tags, and all kinds of craziness here. But there is a better way to filter the results that you get back and maybe find something a little more specific. So let's start with a known ID here. I'm going to use this one. Okay. So, you can see that that is right there. By mousing over it in my inspector I can see that that's where it is in the document. And if I go over here and inspect it I get the Elements Pane in the Web Inspector. I can see where it is and I can also see the rest of the Dom as it currently stands.

So you can see that a page is basically like an outline. We know this from working with HTML, but JQuery also has some methods for getting around inside there and filtering your results. So starting with this, I can say give me everything inside this, using the find method, anywhere it appears no matter where in the Dom. As long as it's inside this that matches this other selector. So find me all the list elements in there. There aren't any. How about anchor tags or lengths? And we have quite a few of those. So, I can use find to give me anything that's anywhere inside this, but I could also use some that are a little more specific.

So I could find all of the children, that's direct children there aren't any of those. But if I don't want to use a specific selector I can just say give me all of the direct children of this element and there they are. When we working with the Dom you'll see these kind of familial type relations mentioned, so I can get all of the parents of this element all the way back to the root element. I can also say give me parents who match a specific selector. So if I just wanted to find this ordered list for example. I could use parents and get that back, and then I can also use siblings, that's one I find myself using a lot. So if I want to see everything that's at the same level as that original one in the Dom, that would be here.

So I would expect to get back this list element and this div. And there they are. So as you can see, there's a great deal of sophistication that you can get into here. These selectors are powered by an engine called, Sizzle. Which you can look up separately. It is included with jQuery but it's its own software project that could be included in other frameworks. All of these selectors are powered by Sizzle, and then jQuery has all these methods like find, and parents and siblings and so forth, that let you filter the results that you found, to get just the elements that you want. Which you can subsequently process using other parts of jQuery.

There are currently no FAQs about jQuery for Web Designers.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed jQuery for Web Designers.

Return to your organization's learning portal to continue training, or close this page.


OK

Upgrade to View Courses Offline

login

With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts.
lynda.com provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now
 

A trusted source for knowledge.

 

We provide training to more than 4 million people, and our members tell us that lynda.com helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.