On select change, how do I pull the selected option’s ID and filter elements of the same class?

Tips and tricks from Tamara Olson Designs

A little jQuery is all that’s needed. (The select has the ID “change-work-category,” and the items to be filtered have the class “work-example-collage.”)

$('#change-work-category').change(function() {
$('.' + $(this).children(":selected").attr("id")).fadeIn();

Share Your Thoughts

About the Author


Tamara Olson is a self-employed UX designer and WordPress developer living in New York City.