Hello, in this jQuery video I am going to show you traversing and finding an element by index. So this is linked with selectors. But if I were to create a bunch of divs what the element is the principal inside a div want and I'm just going to play a total of five of them 234 that was the survey and five. So now if I just change this so there we go. Okay, so Dave, 1234 and five. And before you know the craziness style in here, and I do do the C on the critic class, and this is something red.
And this was a change of color. Now, if I reload, it does nothing because this hasn't been employed by someone apply to the div. Now as we would You know, we selected some div. And we could change the CSS or you know, do dot add class. What what you do afterwards doesn't matter, I haven't done the Find the traversing part yet I want to demonstrate something else. And this is read if I reload, as it's already, but what you might want is only to affect to get a particular item, I only want the first one, the second one, the third one, the fourth one, the fifth one to do these really simple.
So instead of doing something like this, you have your selector as you know, simple complex does not matter. Before the function that you want to do like dot add class dot CSS, whatever it is, you do.eq for element, then you put the actual element itself so for free for example, I'll do dot add class of fee I just do it normally what you will do with that particular item, but this will just be only one item. That's the one at element free. If we reload, we got this one highlighted. in green. We chose element free, but it's highlighted.
Well, the fourth one, remember computers dot 0012, and three. So this is the first one, or the element free, technically, which is the fourth element. So if you want to work out which element you need, please figure out normally as you would, you know, can be like 1234, like that, take away one, and that's the actual element index. So that's how you know use and find an element index, you have your regular selector. After that you did.eq the element that you want to find by a particular index, and then Whatever method you would use that and that's it really, really simple stuff. 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.