Hello, in this jQuery video, I am going to show you how to traverse and get the sibling elements. The first of all, let's add some HTML content and create a div. Inside there, I'm going to create multiple other div and often say, give one person favorite stuff like pizza. Chicken Fried chicken tomorrow. Okay, so if I save that, see what we get. There you go.
So that's what we've got so far. So imagine if I don't have an ID here. So you can be any one of these. I'm just gonna say that This call is mash. So select that element. Now if you are unsure about that, feel free to go and have a look at the selected part of the series for hash map, hash map and hash map we selected in to get to Sydney does Sydney this has selected this selected this element and that this part is returning leave and being the sibling one not the children, not the parent.
Now we can do whatever you want to as we normally would. I'm just going to do a class I've already got a class called Red which will just change the color as in C D or change color to red now. Okay if you want to filter it based on some sort of parameter like your only change or your only you want to traverse the siblings that are Have a certain class, or they have a certain element, you can do that. I'll show you the class example. So far, the class is called epic, epic, epic class. And I will just duplicate this, or common this one.
So in Sydney, this is where you put your filter on see this person dot class. I like classes to have a low case camel case to the first letter. Now, if I go to it, I reload. I didn't see Tony applied it. So what this did this got a element that had an idea mash, which was this one before. Then it said get all the siblings that have a class of AP class, which is the first one and before And then he does something.
In this case, he applied a class called Red, which had this styling and there we go. Remember this little fill extra filtering could be anything. It could be an element type, you could go crazy. If you have any questions, feel free to drop me a message. And as usual, I look forward to seeing you in the next video.