[英]How discover the element with the max font-size
I'm trying to answer the call of a function based on comparison of THIS element (keyword) font-size with font-sizes of other elements: 我正在尝试根据此元素(关键字)的font-size与其他元素的font-size的比较来回答函数的调用:
This is inside a prototype: 这是在原型内:
The self.settings.same is an array with the other elements. self.settings.same是一个包含其他元素的数组。
self.settings.same.forEach(function (item) {
var me = parseInt(self.element.css('fontSize').substring(-1, 2), 10);
var other = parseInt(item.css('fontSize').substring(-1, 2), 10);
if (other > me) {
return false;
}
return true;
});
I want return false if the others elements have the font-size bigger then the current element, but this is not working because it makes the loop only once, so the comparison occurs only once. 如果其他元素的字体大小比当前元素大,我想返回false,但是这不起作用,因为它仅使循环一次,因此比较仅发生一次。
If you can return false only when all others
elements are bigger than me
, then this should work. 如果仅当所有
others
元素都大于me
时才可以返回false,那么这应该可以工作。
self.settings.same.forEach(function (item) {
var me = parseInt(self.element.css('fontSize').substring(-1, 2), 10);
var other = parseInt(item.css('fontSize').substring(-1, 2), 10);
if (other < me) {
return true;
}
});
return false;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.