til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Add and Remove Classes Using JavaScript

You can dynamically remove and add classes for HTML tags quite easily with JavaScript.

const div = document.createElement('div');
div.className = 'foo';

// use the classList API to remove and add classes
div.classList.remove("foo");
div.classList.add("bar", "#baz");

div.classList.remove("bar", "baz");

Resources and References