我在JavaScript plugin中发现了这个getComputedStyle polyfill
if (!computed) {
window.getComputedStyle = function(el) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop === "float") {
prop = "styleFloat";
}
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
};
return this;
};
}getcomputedstyle()是否有jQuery的等价物;
发布于 2013-10-02 21:01:13
您可以使用.css()的getter版本。
来自文档
.css()方法是从第一个匹配的元素中获取样式属性的一种便捷方法,特别是考虑到浏览器访问大多数这些属性的不同方式(基于标准的浏览器中的getComputedStyle()方法与Internet Explorer中的currentStyle和runtimeStyle属性)以及浏览器对某些属性使用的不同术语。
喜欢
$(el).css('color')https://stackoverflow.com/questions/19137507
复制相似问题