I have a filter and used this script for the 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);
}
});
But something is wrong. The price value is 15 or more. But the code never enters the else structure.
Try removing the
$()function call from this line:It should be:
The
$()function returns an object, and all objects are “truthy” so this code would always go into theifblock rather than theelseblock.(By the way, assuming you fix the above problem, within the
ifbranch the expression you are returning!(250 <= price)will always betruebecausepricewill be< 15, so you might as well just sayreturn true;at that point.)