The Power of Changing Classes

Avatar of Chris Coyier
Chris Coyier on

People responded quite positively to “Hey designers, if you only know one thing about JavaScript, this is what I would recommend.” Even the YouTube comments were positive.

Benjamin De Cock mentioned that not only does he agree changing classes is the most important thing a web design can know how to do in JavaScript, he built a mini library around that idea:

It has a really unusual way of configuring it. You use plain language, within a <code> tag, to tell it what classes to change on click, like:

clicking on "h1" removes class "open" on ""
clicking on "h1" adds class "open" on "target"

Here’s a fork of the “level up” demo from that video, done with uilang instead:

See the Pen Change Classes on Stuff by Chris Coyier (@chriscoyier) on CodePen.

Pretty cool.

Jeremy Keith had a good way of putting it too:

It reminds me of the old jQuery philosophy: find something and do stuff to it.

I’d stick to my sentiment as well though. If you’re looking to baby step yourself into JavaScript, learning to select things and changes classes without any library help at all is a great way to do that.