function getCss(ele,attr){
if(window.getComputedStyle){
return window.getComputedStyle(ele,null)[attr];
}else{
return ele.currentStyle[attr];
}
}
获得指定元素的css样式方法
最新推荐文章于 2025-05-21 18:32:13 发布
本文详细介绍了如何使用JavaScript的`getComputedStyle`方法和`currentStyle`属性来获取元素的CSS样式,包括函数实现及不同浏览器之间的兼容性考虑。
804

被折叠的 条评论
为什么被折叠?



