Merge pull request #724 from Siarhei-Zharnasek/master

Simplify hide
This commit is contained in:
Felix Wu
2018-08-29 23:09:41 +02:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

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

View File

@ -1,2 +1,2 @@
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); const hide = els => els.forEach(e => e.style.display = 'none');
module.exports = hide; module.exports = hide;