{"id":2719,"date":"2023-11-14T14:26:31","date_gmt":"2023-11-14T06:26:31","guid":{"rendered":""},"modified":"2023-11-14T14:26:31","modified_gmt":"2023-11-14T06:26:31","slug":"JavaScript removeAttribute()","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/2719.html","title":{"rendered":"JavaScript removeAttribute()"},"content":{"rendered":"
element.removeAttribute<\/span>(attributename)
<\/span><\/code><\/pre>\n<\/div>\n\u53c2\u6570\u503c<\/h3>\n\n \u5c5e\u6027\u540d\u79f0\uff1a<\/strong>\u8fd9\u662f\u5fc5\u9700\u7684\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a\u8981\u4ece\u5143\u7d20\u4e2d\u5220\u9664\u7684\u5c5e\u6027\u540d\u79f0\u3002\u5982\u679c\u8be5\u5c5e\u6027\u4e0d\u5b58\u5728\uff0c\u5219\u8be5\u65b9\u6cd5\u4e0d\u4f1a\u4ea7\u751f\u4efb\u4f55\u9519\u8bef\u3002\n<\/div>\n\n \u901a\u8fc7\u4f7f\u7528\u4e00\u4e9b\u793a\u4f8b\u8ba9\u6211\u4eec\u7406\u89e3\u5b83\u3002\n<\/div>\n Example1 <\/h3>\n\n \u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6709\u4e24\u4e2a\u6bb5\u843d\u5143\u7d20\uff0c\u5176ID\u4e3a
\n para <\/strong>\u548c
\n para1 <\/strong>\u5c5e\u4e8e\u540c\u4e00\u7c7b
\n jtp <\/strong>\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u5220\u9664\u8fd9\u4e9b\u6bb5\u843d\u5143\u7d20\u7684
\n class <\/strong>\u5c5e\u6027\u3002\u6211\u4eec\u5fc5\u987b\u5355\u51fb\u7ed9\u5b9a\u7684 HTML\u6309\u94ae\u624d\u80fd\u770b\u5230\u6548\u679c\u3002\n<\/div>\n\n <!DOCTYPE html>
<html>
<head>
<title>
The removeAttribute Method
<\/title>
<style>
.jtp {
color: red;
background-color: yellow;
}
<\/style>
<\/head>
<body>
<p>
Welcome to the bianchenghao6.com
<\/p>
<p>
Example of the removeAttribute() Method
<\/p>
<p id = \"para\" class = \"jtp\">
This is a paragraph element.
<\/p>
<p id = \"para1\" class = \"jtp\">
This is second paragraph element.
<\/p>
<button onclick = \"fun()\">
Click me!
<\/button>
<script>
function fun() {
document.getElementById<\/span>(\"para\").removeAttribute<\/span>(\"class\");
document.getElementById<\/span>(\"para1\").removeAttribute<\/span>(\"class\");
}
<\/script>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/div>\n\n \u8f93\u51fa<\/strong>\n<\/div>\n\n