JSFiddle - React, Tailwind, and code Playground
HTML
<fieldset class="filter-list__item selected" style="margin-bottom:20px;">
<h3>Фильтр товаров</h3>
<div class="filter-list__inner">
<h5>Цена, руб</h5>
<div class="horizontal-slider">
<div class="formCost">
<div class="formCost__left">
<label>от</label>
<input type="text" name="min_price" id="min_price" class="min-cost" value="0">
</div>
<div class="formCost__right">
<label>до</label>
<input type="text" name="max_price" id="max_price" class="max-cost" value="30000000">
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div id="price-range" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all"><div class="ui-slider-range ui-widget-header ui-corner-all" style="left: 0%; width: 100%;"></div><span class="ui-slider-handle ui-state-default ui-corner-all" tabindex="0" style="left: 0%;"></span><span class="ui-slider-handle ui-state-default ui-corner-all" tabindex="0" style="left: 100%;"></span></div>
</div>
</div>
<div class="filter-list__inner">
<input id="inverter" name="inverter" value="1" type="checkbox"/>
<span> INVERTER</span>
</div>
<div class="filter-list__inner">
<h3>Производитель</h3>
<ul class="filter-list__inner__brands">
<li class="first-child">
<input name="brand" value="1" type="checkbox"/>
<a href="">Electra</a>
</li>
<li class="first-child">
<input name="brand" value="2" type="checkbox">
<a href="">Electrolux</a>
</li>
<li class="first-child">
<input name="brand" value="3" type="checkbox"/>
<a href="">generalclimate</a>
</li>
<li class="first-child">
<input name="brand" value="4" type="checkbox"/>
<a href="">Hitachi</a>
</li>
<li class="first-child">
...
CSS
#kod-pr-catalog{
float:left;
width:63%;
margin-left:2%
}
.filter-list__item{
float:left;width:30%
}
JavaScript
jQuery('#filter-products').click(function(){
var price_from = jQuery('#min_price').val();
var price_to = jQuery('#max_price').val();
var inverter = jQuery('#inverter').val();
var brands = [];
var brands = jQuery("input[name='brand']:checked").map(function() {
return parseInt( $(this).val() );
}).get();
if ( jQuery.isNumeric( price_from ) ) {
price_from = parseInt(price_from);
}else{
price_from = 0;
}
if ( jQuery.isNumeric( price_to ) ) {
price_to = parseInt(price_to);
}else{
price_to = 30000000;
}
jQuery('#kod-pr-catalog .new-pr').hide().filter(function() {
var brand = parseInt($(this).data('brand'));
if ( jQuery('#inverter').is(":checked") && ( brands.length <= 0 ) && ( jQuery(this).data('price') >= price_from && jQuery(this).data('price') <= price_to ) ) {
console.log( "invertor ");
return ( ( jQuery(this).data('inverter') == '1' ) && ( jQuery(this).data('price') >= price_from && jQuery(this).data('price') <= price_to ) );
} else if ( jQuery('#inverter').is(":checked") && ( brands.length > 0 ) && ( jQuery(this).data('price') >= price_from && jQuery(this).data('price') <= price_to ) ) {
console.log( "invertor dd");
return ( ( jQuery.inArray( brand, brands ) > -1 ) && ( jQuery(this).data('inverter') == '1' ) && ( $(this).data('price') >= price_from && jQuery(this).data('price') <= price_to ) );
} else if ( !jQuery('#inverter').is(":checked") && ( brands.length > 0 ) && ( jQuery(this).data('price') >= price_from && jQuery(this).data('price') <= price_to ) ) {
console.log( brands.indexOf( brand ) );
return ( ( brands.indexOf( brand ) >= 0 ) && ( jQuery(this).data('inverter') == '0' || jQuery(this).data('inverter') == '' ) && ( $(this).data('price') >= price_from && $(this).data('price') <= price_to ) );
} else if ( !jQuery('#inverter').is(":checked") && ( brands.length <= 0 ) && (...