跳到主要内容

hide

TS JS

Hides all the elements specified.

Use NodeList.prototype.forEach() to apply display: none to each element specified.

typescript
const hide = <T extends HTMLElement>(...el: T[]) =>
[...el].forEach((e) => (e.style.display = "none"));
typescript
hide(document.querySelectorAll("img")); // Hides all <img> elements on the page