在Firefox,Opera和IE中我可以通过以下方式获取它们:
>> for (k in document.body.style) console.log(k) -> opacity background height textAlign . ... long list ... . pointerEvents
在WebKit中,结果完全不同:
>> for (k in document.body.style) console.log(k) -> cssText length parentRule getPropertyValue getPropertyCSSValue removeProperty getPropertyPriority setProperty item getPropertyShorthand isPropertyImplicit
更新:最新的WebKit确实在HTMLElement.style中枚举CSS属性,与所有浏览器相同.
我可以使用 JavaScript 获取 css 属性的所有值吗?例如,我可以获得“cursor”属性的所有值(poniter、resize 等)吗?
我知道我可以从元素获取属性的值
element.style.cursor
Run Code Online (Sandbox Code Playgroud)
但这显然无法向我展示所有可能的值。