我有一个贯穿一些div的函数,在每个div中它计算了孩子的数量.然后根据子的数量(var 长度),它做了一些事情.
$('.member-type').each(function() { var length = $(this).children('.views-row').length; if (length >= 2){ console.log('equal to or more than two'); } else if (length > 5){ console.log('more than five'); } else{ console.log('single item'); } });
第一个if语句有效,else语句有效.但由于某种原因,else if语句不起作用,即使长度大于5(我在控制台日志中检查).
有谁知道我做错了什么?