Skip to main content
CSS-Tricks
  • Articles
  • Videos
  • Almanac
  • Newsletter
  • Guides
  • DigitalOcean
  • DO Community
Search

Articles Tagged
classlist

3 Articles
{
,

}
Direct link to the article How to Cycle Through Classes on an HTML Element
classes classlist JavaScript

How to Cycle Through Classes on an HTML Element

Say you have three HTML classes, and a DOM element should only have one of them at a time:

<div class="state-1"</div<div class="state-2"</div<div class="state-3"</div

Now your job is to rotate them. That is, cycle through classes …

Avatar of Chris Coyier
Chris Coyier on Jan 26, 2022
Direct link to the article Body Toggle
classlist JavaScript

Body Toggle

I appreciate the clarity of this trick that Mikael Ainalem posted over on Reddit:…

Avatar of Chris Coyier
Chris Coyier on Jul 6, 2021
accordion classlist JavaScript smacss state management

Managing State in CSS with Reusable JavaScript Functions

Determining the most efficient way of managing state can be a challenging issue in CSS, but thankfully there are many OOCSS-based methodologies out there which provide some good solutions. This article is all about managing the attributes that help with state through JavaScript in efficient ways.

Avatar of Luke Harrison
Luke Harrison on Apr 28, 2017 (Updated on May 30, 2017)

CSS-Tricks is powered by DigitalOcean.

Keep up to date on web dev

with our hand-crafted newsletter

DigitalOcean
  • DigitalOcean
  • DigitalOcean Community
  • About DigitalOcean
  • Legal
  • Free Credit Offer
CSS-Tricks
  • Email
  • Guest Writing
  • Book
  • Advertising
Follow
  • Mastodon
  • Twitter
  • Instagram
  • YouTube
  • CodePen
  • iTunes
  • RSS
Back to Top