Files
30-seconds-of-code/snippets/hide.md
2017-12-28 23:33:21 +02:00

322 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.querySelector('img')); // Hides all <img> elements on the page