获取设置dom属性

getAttribute():获取dom节点属性,带一个参数,表示要获取的属性
使用方法:object.getAttribute("id");

setAttribute():设置dom节点属性,带两个参数,前面为设置的属性,后者为要设置的值
使用方法:object.setAttribute("id", "name");

removeAttribute():删除属性,带一个参数,表示要删除的属性
使用方法:object.removeAttribute("class");

原文地址:https://www.cnblogs.com/qiangspecial/p/3183590.html