Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 492 Bytes

add_and_remove_classes_using_javascript.md

File metadata and controls

18 lines (12 loc) · 492 Bytes

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