Files
30-seconds-of-code/snippets/hide.md
Angelos Chalaris 1215889c11 Update hide.md
2017-12-29 00:01:19 +02:00

325 B

hide

Hides all the elements specified.

Use the spread operator (...) and Array.forEach() to apply display: none to each element specified.

const hide = (...el) => [...el].forEach(e => e.style.display = 'none');
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page