Is the 'getPropertyValue' method required for retrieving CSS?

后端 未结 2 915
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 05:30

Could you tell me why we need to use the getPropertyValue method if we can use only the getComputedStyle one?

For example, this will work,

2条回答
  •  鱼传尺愫
    2021-01-18 05:55

    I believe it is for properties that can't be dot-notationed, like background-position. Though I suppose that brings up the question "why not use brackets notation, i.e. getComputedStyle(element, null)['background-position']?". It's possible they just wanted a getter method for the class (CSSStyleDeclaration).

提交回复
热议问题