jQuery class selector isn’t selecting my class

If this is true, it most likely is not an issue with jQuery, but rather your class name. Class names follow naming conventions used in most modern programming languages (case sensitive, no symbols, etc.).

If your class name doesn't follow the rules, JavaScript will have a hard time finding it in the DOM.

The root of this problem no doubt points to the all-to-forgiving web browser HTML rendering engine. Today's browsers will allow anything that somewhat resembles valid HTML to be rendered properly, without error.

Further than that, I haven't to date found a good HTML editor which points out things like invalid class names.

These importance of sticking to the HTML specification doesn't become apparent to most web developers until problems like these arise. I'm guilty of it myself.

The HTML specification is very long and certainly not a page-turner! But, it pays to learn it a little bit at a time.

Why follow me on Twitter?

  • I tweet about new technologies, services or libraries I find interesting
  • Yeah, sometimes I'll post a pet-peeve or rant about something trivial
  • If I discover something that made my web development life easier, I share it
  • I'll shout out any handy tip that I think might be useful to other devs


Tagged .

Updated: 2012-02-19

Phil LaNasa follow us in feedly