【问题标题】:Is there some way to remove the "hidden" attribute in all elements of a page?是否有某种方法可以删除页面所有元素中的“隐藏”属性?
【发布时间】:2021-04-13 01:50:34
【问题描述】:

我一直在尝试创建一个小书签来取消隐藏网页上的所有内容,但它一直没有工作。这是我到目前为止的代码:

document.getElementsByTagName(*)[0].removeAttribute("hidden")

我需要做什么才能取消隐藏所有元素?

编辑:我在下面链接的问题中找到了一行代码,感谢您的帮助!

<p>Hi there</p>
<p hidden>This is hidden p text</p>
<b hidden>This is also hidden text with the bold tag</b>
<br><br/>

<button onclick="unhide()">Click Me</button>

<script>
  function unhide() {
    document.querySelectorAll("*").forEach(b => b.removeAttribute('hidden'));
  }
</script>

【问题讨论】:

标签: attributes hidden bookmarklet


【解决方案1】:

【讨论】:

  • 谢谢!我修改了在那里找到的一行代码,它取消了所有内容!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-29
  • 1970-01-01
  • 2017-03-04
  • 2015-10-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多