filter - Get cheapest
jQuery
by Sparrow Squire
HTML
<div id="refine-section-1">
<label><input type="checkbox">Filter 1 <span>£300</span></label>
<label><input type="checkbox">Filter 2 <span>£200</span></label>
<label><input type="checkbox">Filter 3 <span>£100</span></label>
<span class="clear-filters">Clear</span>
</div>
<div id="refine-section-2">
<label><input type="checkbox">Filter 4 <span>£400</span></label>
<label><input type="checkbox">Filter 5 <span>£500</span></label>
<label><input type="checkbox">Filter 6 <span>£600</span></label>
<span class="clear-filters">Clear</span>
</div>
<div id="refine-section-3">
<label><input type="checkbox">Filter 7 <span>£900</span></label>
<label><input type="checkbox">Filter 8 <span>£700</span></label>
<label><input type="checkbox">Filter 9 <span>£800</span></label>
<span class="clear-filters">Clear</span>
</div>
<div id="refine-section-4">
<select>
<option value="">--</option>
<option value="text1">1</option>
<option value="text2">2</option>
</select>
<span class="clear-filters">Clear</span>
</div>
<div id="refine-section-5">
<select>
<option value="">--</option>
<option value="text3">3</option>
<option value="text4">4</option>
</select>
<span class="clear-filters">Clear</span>
</div>
JavaScript
function cheapestFilter(id) {
$(id).each(function(){
var priceArray = new Array();
$(this).find('label span').each(function(){
priceArray.push($(this).text().replace('£', ''));
});
console.log(Math.min.apply(Math,priceArray));
});
}
cheapestFilter('#refine-section-1');
cheapestFilter('#refine-section-2');
cheapestFilter('#refine-section-3');