Kebab file names

This commit is contained in:
Angelos Chalaris
2023-04-27 21:58:35 +03:00
parent 1d189c709a
commit 61200d90c4
440 changed files with 0 additions and 0 deletions

21
snippets/add-class.md Normal file
View File

@ -0,0 +1,21 @@
---
title: Add class to HTML element
tags: browser
author: chalarangelo
cover: budapest-palace
firstSeen: 2020-12-30T19:21:15+02:00
lastUpdated: 2020-12-30T19:21:15+02:00
---
Adds a class to an HTML element.
- Use `Element.classList` and `DOMTokenList.add()` to add the specified class to the element.
```js
const addClass = (el, className) => el.classList.add(className);
```
```js
addClass(document.querySelector('p'), 'special');
// The paragraph will now have the 'special' class
```