【发布时间】:2016-01-13 11:45:43
【问题描述】:
我每个人都在运行 jQuery。我需要检查每次循环中的条件是否为真,那么它是否为真,否则即使它为假,也为假。
jQuery(".class span").each(function(){
var attr_Val = parseInt($(this).attr("data-value"));
if(parseInt(product_obj.length) == attr_Val)
{
// if it was true every time, then set its True. Else False
}
});
【问题讨论】:
-
您想知道选择器匹配的所有元素的条件是否为真吗?如果是这样,
each不适合使用...您可能想要reduce
标签: jquery