Child Elements

2 minutes
Share the link to this page
Copied
  Completed
A descendant is a child, grandchild, great-grandchild, and so on. With jQuery you can traverse down the DOM tree to find descendants of an element.

Transcript

Hello, in this jQuery video I'm going to show you traverse in but traversing boy children. So if we go to our HTML file, we got the div, I am going to create one more div, you can think of this parent will contain all of these other dudes. Save it. There we go, what we're going to say is a child element of the day, tomorrow, you know what the Child Element isn't necessarily any child element, we are going to affect, you know, do something to it's not the div itself, not by class, but any child element. So what you do is you select the parent and then you can do whatever select you want. So I'm just keeping it simple.

They've got children. And I'm just going to add class. And I've already got a class right here, which is red changes the color to red, red class. Reload, as you can see all of them all read now. Whereas if I was to create a narrative, a Hello World in that text is black, because this is not a child of day. This is just the content of this.

So these Act and the content and the children of the so Child Elements, so that is applies, you know, whatever you do anything to have to be add classical, whatever you want. But this just does it to every child, if you want to do a bit of filtering. So maybe I have let's have Hello, for example, and I have no class well, so I only want to apply the red class to elements there are children of a div element, but I have the class of Hello. So you do something very similar to this community or one Instead of just doing dot children pass in an optional parameter, which acts as you know, your filter, and there's quite a few things that you can do with this bombs can keep it simple and say dot Hello. Now if we reload, I didn't see only those that only the elements that were to drum up a development that also had a class of Hello.

Had this class added. That's it simple stuff. If you have any questions, feel free to pop me a message. And as usual, I look forward to see you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.