Rename js snippets

This commit is contained in:
Angelos Chalaris
2023-05-19 20:23:47 +03:00
parent 82a614e42e
commit 9d032ce05e
305 changed files with 70 additions and 70 deletions

View File

@ -0,0 +1,22 @@
---
title: Remove class from HTML element
type: snippet
language: javascript
tags: [browser]
author: chalarangelo
cover: bag-waiting
dateModified: 2020-12-30T19:21:15+02:00
---
Removes a class from an HTML element.
- Use `Element.classList` and `DOMTokenList.remove()` to remove the specified class from the element.
```js
const removeClass = (el, className) => el.classList.remove(className);
```
```js
removeClass(document.querySelector('p.special'), 'special');
// The paragraph will not have the 'special' class anymore
```