dom设置与获取 getAttribute()setAttribute() removeAttribute()

语法   获取自定义标签的属性

ele.getAttribute("attrbute");

var p = document.getElementById("text");

console.log(p.getAttribute("class"))

添加属性

p.setAttribute(“data-color”,"red");

 

删除属性

p.removeAttribute(“align”);

posted @ 2018-09-21 10:54  键1234  阅读(303)  评论(0编辑  收藏  举报