js设置html属性和CSS属性

js设置html属性:

(1)添加属性

对象名.属性名=值

对象名.setAttribute("属性名","值")

(2)删除属性

对象名.removeAttribute("属性名")

(3)获取属性

对象名.getAttribute("属性名")


js设置CSS属性:    

(1)添加属性

对象名.style.属性名=值

对象名.style.setProperty("属性名","值"[,"优先级"])

(2)删除属性

对象名.style.removeProperty("属性名")

(3)获取属性

对象名.style.getPropertyValue("属性名")

(4)设置对象的所有css属性

对象名.style.cssText="以分号分隔的多个css属性"