0
点赞
收藏
分享

微信扫一扫

显示指定的所有元素

黎轩的闲暇时光 2022-07-27 阅读 141

使用扩展运算符(​​…​​​)和 ​​Array.prototype.forEach()​​​ 移除每个指定元素的 ​​display​​ 属性。

const show = (...el) => [...el].forEach(e => (e.style.display = ''))

// 显示页面上的所有 <img> 元素
show(...document.querySelectorAll('img'))

举报

相关推荐

0 条评论