snipplets.dev/snipplets/code/JavaScript/addClass.js

6 lines
170 B
JavaScript
Raw Normal View History

2022-03-26 03:37:19 +03:00
// Use element.classList.add to add a class:
element.classList.add('my-class');
// And element.classList.remove to remove a class:
element.classList.remove('my-class');