我有一个过滤器,并使用这个脚本的过滤器。jQuery if if else else filter
filteredData = filteredData.filter(function() {
var elm = $(this),
price = parseInt('0' + elm.attr('data-price'), 10) || 0;
if ($(price < 15)) {
return !(250 <= price);
} else {
return !(sliderData <= price);
}
});
但是有什么不对。价格值是15或更多。但是代码永远不会进入else结构。
你'if'实际上是评估一个jQuery对象( '$(...)') - if检查中的任何非空/非falsey值将导致检查通过,if中的代码将被评估 – nbrooks 2012-07-10 05:56:35