MoreLesson 228Free preview
Remove Class
This lesson is part of How To · All levels
Summary
Remove class removes one or more classes from the element without interfering with the other classes. The method is a modern method that is safe because it does not cause error if a class is not found. After the class is deleted, the element returns to the CSS-defined basic style.
Key points
- ClassList.remove('name') removes a certain class of elements
- Several classes can be deleted at once with separate arguments
- Deleting a class that doesn't exist doesn't cause an error
- Avoid emptying className because it will delete all classes
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.