From the course: jQuery Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Attribute filters - jQuery Tutorial
From the course: jQuery Essential Training
Attribute filters
- You can get pretty far using the basic jQuery filters but you'll run into scenarios where you need a little bit more power. jQuery provides some more advanced filters which we'll take a look at now. So in your code editor, open up the AttrFilters_start file. The attribute filters in jQuery let you perform various tests to see if attributes are present and optionally contain certain values. In this first example, I'll write a jQuery selector that's looking for paragraph tags. And for attribute filters, we put the attributes inside square brackets. Let me go ahead and write the code for that. I'm gonna write p, and then class inside these square brackets and then I'll use my CSS function to highlight it. In this case, my selector looks for paragraph tags and using this syntax, the name of the attribute inside these square brackets, it's looking for paragraph tags that have a class attribute and in this case, we don't care what the value is. We're just testing to see if it's there. If…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Overview of selectors and filters1m 57s
-
(Locked)
Basic selectors4m 27s
-
(Locked)
Basic filters5m 59s
-
(Locked)
Advanced selectors5m 3s
-
(Locked)
Attribute filters4m 44s
-
(Locked)
Advanced filters6m 48s
-
(Locked)
Traversing documents with jQuery9m 57s
-
(Locked)
jQuery statement chaining1m 18s
-
(Locked)
Programming challenge2m 43s
-
(Locked)
Solution2m 32s
-
-
-
-
-
-