gpt4 book ai didi

php - 使用 dom 从 HTML 中删除所有内联样式标签

转载 作者:可可西里 更新时间:2023-11-01 01:05:42 25 4
gpt4 key购买 nike

我有一个 dom,我在其中加载了整个网页 html。我想从该页面的所有元素中删除所有内联样式。我怎样才能做到这一点。

最佳答案

var all = document.getElementsByTagName("*");

for (var i=0, max=all.length; i < max; i++) {
// Do something with the element here
all[i].removeAttribute("style","")
}

关于php - 使用 dom 从 HTML 中删除所有内联样式标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11468585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com