Hide elements
JavaScript, Browser, CSS · Sep 15, 2020

Hides all the elements specified.
- Use the spread operator (
...
) andArray.prototype.forEach()
to applydisplay: 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