Different ways of accessing attribute values using javascript

前端 未结 4 876
生来不讨喜
生来不讨喜 2020-12-14 18:02
document.getElementById(\'myId\').style;

is one way of accessing the style attribute.. Also we can do the same using document.getElementById

4条回答
  •  有刺的猬
    2020-12-14 18:33

    getAttribute will return the value of non-standard attributes as well as standard ones.

    Object property notation will not, since non-standard attributes aren't converted to properties.

     ... 
    

提交回复
热议问题