Hello in this jQuery video we are going to select elements based on a attribute. So let's just create a few elements. So I know operate just because can be very simple. And I'm gonna say element one and I'm going to add a attribute to this. So I am going to add an attribute or do maybe we add a target attributes from the from the school and our second one blank put this hello and we'll remove the target from the We are going to check if this particular attribute could actually be any attribute and then just the number, but we're just gonna stick with target blank. Once you understand this, you'll be good to go.
When we're going to detect if a element is clicked, or more specifically, a div is clicked, that has a attribute called target, and it has the value of blank and we can do this so really simple. div. Now we put square brackets indicate we are checking for an attribute. The target is the name of the attribute equals single quotation marks, not double could do conflict with this. Otherwise you can slip them around if you want double inside, and then here was going to put underscore blank click so click function We're just going to do a console log console dot log. And I'm gonna say target is blank, save that reload.
And if we go back, only the first two should trigger it, that trigger that triggers it. That triggers that. Third one does not trigger it, even though you're the target, it is not. The value is different, and the final one shouldn't trigger it. So that's how you selected based on attributes or to set the target attribute could be any attribute and any value. So that's it.
Thanks for watching. If you have any questions, feel free to call me message and as usual, I look forward to seeing you in the next video.