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.

Subscribe

  • follow us in feedly


Tagged .

Updated: 2012-02-19

Phil LaNasa