<!DOCTYPE html>
<html>
<meta charset="UTF-8" />
<body>
<h1 style="display: none;">Hello World!</h1>
<p id="demo">点击按钮来删除标题中的 style 属性。</p>
<button οnclick="myFunction()">确定</button>
<script>
function myFunction() {
document.getElementsByTagName("H1")[0].removeAttribute("style");
}
</script>
</body>
</html>
如下图:
(1)
使用JavaScript脚本删除元素属性
最新推荐文章于 2022-06-05 16:11:24 发布