Files
30-seconds-of-code/snippets/hide.md
Angelos Chalaris 611729214a Snippet format update
To match the starter (for the migration)
2019-08-13 10:29:12 +03:00

16 lines
345 B
Markdown

---
title: hide
tags: browser,css,beginner
---
Hides all the elements specified.
Use `NodeList.prototype.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
```