Front-End Development Javascript jQuery Plugin

Authored by Corey Ballou

jQuery getMatchingClass Plugin

The getMatchingClass plugin is useful for determing whether a singular matching element contains a particular partial class name. The idea behind the function is to allow for partial matching using the following jQuery selectors:

  • $= – “ends with” selector
  • ^= – “starts with” selector
  • *= – “contains” selector
  • = – “matches” selector

The plugin is useful in the event you need to determine if an element contains a portion of a class name utilizing already known jQuery selectors. Unfortunately this functionality did not exist within the Sizzle selector engine. Improvements and bugfixes are always welcome.

Source Code

Example Usage

To reiterate, this plugin is only useful in very specific cases. My initial use case involved handling a lightbox with class variances to allow for complete changes in styling.

Author: Corey Ballou

Corey Ballou is the CEO of Whether you're a student, young professional, entrepreneur, startup, or small business, you can be up and online fast with your own custom domain, email, and webpage on POP. Corey is a professional PHP developer by trade, specializing in custom web applications development for startups, small businesses, and agencies. Follow Corey on Twitter @cballou.