美文网首页
getAttribute setAttribute setPro

getAttribute setAttribute setPro

作者: 三人_ | 来源:发表于2019-03-10 11:13 被阅读0次

getAttribute setAttribute 用来获取和设置元素固有的属性,如title,target,href,class等等
注:获取类需要用className
setProperty 用来添加或修改元素的样式
object.setProperty(propertyname, value[, priority])

设置一个新的 CSS 属性,并使用 "important" 优先级:

var demo = document.querySelector('#demo').style;
demo.setProperty("background-color", "yellow", "important");

相关文章

网友评论

      本文标题:getAttribute setAttribute setPro

      本文链接:https://www.haomeiwen.com/subject/qwkupqtx.html