Files
30-seconds-of-code/snippets/hide.md
Angelos Chalaris 96057709a1 Update hide.md
2018-01-08 12:41:36 +02:00

14 lines
330 B
Markdown

### hide
Hides all the elements specified.
Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified.
```js
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
```
```js
hide(...document.querySelectorAll('img')); // Hides all <img> elements on the page
```