我在一个中找到了这个 getCompulatedStyle polyfillJavaScript 插件 https://github.com/viljamis/responsive-nav.js
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;
};
}
getcompulatedstyle(); 是否有任何 jQuery 等效项?
您可以使用 getter 版本.css() http://api.jquery.com/css/.
From doc
.css() 方法是从样式属性获取样式属性的便捷方法
第一个匹配的元素,特别是考虑到不同的方式
浏览器访问大多数这些属性( getCompulatedStyle()
基于标准的浏览器中的方法与 currentStyle 和
Internet Explorer 中的runtimeStyle 属性)和不同术语
浏览器用于某些属性。
like
$(el).css('color')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)