质量为本、客户为根、勇于拼搏、务实创新
js的实用操作之removeAttribute
removeAttribute是JavaScript中的一个实用操作,用于从一个HTML元素中移除指定的属性。语法:element.removeAttribute(attributeName)参数说明:
示例:假定我们有一个元素,并且它有一个名为"disabled"的禁用属性。我们可使用removeAttribute操作来移除这个禁用属性。
var btn = document.querySelector("button"); btn.removeAttribute("disabled");
这样,我们就成功地从元素中移除"disabled"属性。
TOP