Hello, in this jQuery video, I'm going to show you traversing I'm going to show you the filtering part of it. So when we actually before we get on to the jQuery part that's great about HTML. I'm going to create a bunch of div the elements, the complexity doesn't matter. Once you get to grips with selectors, which were a separate section in this series, you can check out then you're able to go on campus some of my favorite foods of pizza. Fried chicken or fried chicken today, I literally just had a stone, waffles, ice cream, finger and that's also a real mind match. Okay, so if I reload it, see what we get.
We get, you know, five items as simple stuff. If I do a selector, so if I just select Dear audience, and I want to you know, modify it. Let's say I want to add a class. to want to know more about this sort of stuff, feel free to check it out in the series of videos covering it in the HTML and CSS section, and the attributes as well. So I'm saying read, I've got this customer class right here, we just changed the text color to red. So there we go, it's all red.
But you know, it changes all of it. If we want a bit more flexibility, what we can do. So this is select everything. And if maybe you only want to select the item, before you do, you know dot add class or dot CSS or you know, whatever you want to do to your particular element I selected go here you do dot this is where you filter it. First, and this will just get the first one. So if I save it now, it just gets the first one, whenever the one picked up or if there's a bit of is literally the first one.
My thinking, is there a way that we can do this for the last item? If you're thinking that you're right there is and you can get guess what is select the last item, it is literally left by reload. It just modifies the last one. Okay, so pretty cool. In number one that you can do, which I actually covered this in the separate video, which is selecting by index. So select by index.
So if you want to know more about that, feel free to check that video in just put EQ select the index number. So if I say one for example uncomment this and see which one is you know, how the red class applied to it. Am I thinking why is this One even though we chose one member computer, start with zero. So the first, you know, element is this one, it's the one at index zero. Okay, so that's the, you know, index want. Another way you can do, there's another method that you can do which is called dot filter, a bit more thought of complex look like copy this filter.
So that you put filter, but you can filter based on something like if we had a certain class. So if I, if I say, only do it to the ones that have the class of 10 Oh, at the moment, you're applied to nothing. If I go back, however, and let's say if I say class of Hello Hello as well. And if I reload, as you can see, it's a get all the divs will filter it to the ones that have the class which in this dot indicates class, the class of Hello, you could have an opera commerce say you know this or that class you know, any sort of filtering or any sort of conditions that you could put know in this selector here, you can do that as well as the component element type, or you can also do is something called the knot and that allows you to say anything that doesn't match this condition.
So if I just change this to not filter based filter not based on a condition and I reload it now what you'll see is the opposite ones have the class the red class applied, so wait does it get ordered. Then it says filter it to anything that doesn't crease the not keyword doesn't have this Hello class and then he adds the class of Read so that they will train when you're traversing items really powerful, really useful stuff. It really helps you know instead of having to you know create multiple classes and ID for this and ID for that just because you know, you find it difficult to get deep particular item that you want, maybe you want you know, always the last one, maybe the has some sort of special styling, and this will allow you to easily do that. If you have any questions, feel free to call me a message.
And as usual, I look forward to seeing you in the next video.