扫码关注官方订阅号
window.getComputedStyle(elem,null).getPropertyValue(“style”)和window.getComputedStyle(elem,null).style有什么区别
学习是最好的投资!
window.getComputedStyle(elem,null)返回`CSSStyleDeclaration对象这个对象有getPropertyValue`方法获取对应css属性的值例如 getPropertyValue('color');//获取字体颜色子
window.getComputedStyle(elem,null)
`CSSStyleDeclaration
getPropertyValue
getPropertyValue('color')
CSSStyleDeclaration是没有style属性的
你是不是想问window.getComputedStyle(elem,null).getPropertyValue(“color”)和window.getComputedStyle(elem,null).color有什么区别有区别,属性值是不同的访问方式在访问例如background-color类似格式的css属性时`window.getComputedStyle(elem,null).background-color就不可以了,需要使用window.getComputedStyle(elem,null).backgroundColor访问window.getComputedStyle(elem,null).getPropertyValue(“background-color”)是可以的
`window.getComputedStyle(elem,null).background-color
window.getComputedStyle(elem,null).backgroundColor
window.getComputedStyle(elem,null).getPropertyValue(“background-color”)
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
window.getComputedStyle(elem,null)返回`CSSStyleDeclaration对象这个对象有
getPropertyValue`方法获取对应css属性的值例如
getPropertyValue('color');//获取字体颜色子CSSStyleDeclaration是没有style属性的
你是不是想问
window.getComputedStyle(elem,null).getPropertyValue(“color”)和window.getComputedStyle(elem,null).color有什么区别
有区别,属性值是不同的访问方式
在访问例如background-color类似格式的css属性时
`window.getComputedStyle(elem,null).background-color就不可以了,需要使用window.getComputedStyle(elem,null).backgroundColor访问window.getComputedStyle(elem,null).getPropertyValue(“background-color”)是可以的