The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Manipulate the DOM with the classList API

Manipulate the DOM with the classList API

3:26
Learn how to add, remove and test for CSS classes using the classList API. It's more powerful than using `className` and doesn't require any dependencies.
Watch this lesson now
Avatar
egghead.io

Learn how to add, remove and test for CSS classes using the classList API. It's more powerful than using className and doesn't require any dependencies.

Avatar
Thomas

I guess you can have only one button named "toggle filter" (or even a dynamic button text which changes depending on whether the class is applied or not) and then just use classList.toggle('filtername') without a second attribute, which is essentially how .toggle works. (just saying it because it's not clear from the video)

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?