【发布时间】:2015-06-10 19:02:18
【问题描述】:
我有一个函数,它检查两个 DOM 元素的计算样式属性值,如果每个属性都相等,它应该返回 true 或 false。
checkUserBlock: function (userBlockSelector, properties) {
var checker = this.setCheckingStyle(userBlockSelector, properties);
var userBlockCompStyle = getComputedStyle(this.getUserBlock(userBlockSelector));
var checkBlockCompStyle = getComputedStyle(checker);
var checkingStyle = this.parseCheckingStyle(properties);
for(var key in checkingStyle){
return (userBlockCompStyle.getPropertyValue([key].toString()) == checkBlockCompStyle.getPropertyValue([key].toString()));
}
}
我在返回所有属性的结果时遇到问题,我考虑了 every() 函数,但它仅适用于数组。我如何将它用于对象,或者您可以在没有 jQuery 的情况下提供不同的解决方案?
【问题讨论】:
标签: javascript object for-loop