本文介绍了相当于getcomputedstyle()的jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在中找到了getComputedStyle polyfill
if(!calculated){
window.getComputedStyle = function(el){
this.el = el;
this.getPropertyValue = function(prop){
var re = /(\ - ([a-z]){1})/ g;
if(prop ===float){
prop =styleFloat; $ re $ test(prop)){
prop = prop.replace(re,function(){
return arguments [2] .toUpperCase();
b $ b});
}
返回el.currentStyle [道具]? el.currentStyle [prop]:null;
};
返回此;
};
$ b 是否有与getcomputedstyle();相同的jQuery对象? $ b
解决方案您可以使用 .css()
$(el).css('color')
I found this getComputedStyle polyfill in a JavaScript plugin
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;
};
}
Is there any jQuery equivalent for getcomputedstyle();
解决方案 You can use the getter version of .css().
From doc
like
$(el).css('color')
这篇关于相当于getcomputedstyle()的jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!