我想在过滤器中写入过滤器。我从#34; Spring"在UI上这段代码:
<div th:each="curtain : ${allCurtain}">
<div class="color" th:classappend="${curtain.color} +' '+ ${curtain.paint}">
<div class="pic" id="mainDiv">
过滤器菜单有这样的外观:
<div class="searchColor" id="filterColor">
<div class="searchTextColor"> Color: </div>
<input type="checkbox" name="rbn" id="white" value="white" />white
<br/>
<input type="checkbox" name="rbn" id="beige" value="beige"/>beige
<br/>
<input type="checkbox" name="rbn" id="cream" value="cream"/>cream
<br/>
<input type="checkbox" name="rbn" id="gold" value="gold"/>gold
<br/>
</div>
<div class="searchColor" id="searchPaint">
<div class="searchTextColor"> Paint:</div>
<input type="radio" name="paintRbn" id="abstract" value="abstract" />abstract
<br/>
<input type="radio" name="paintRbn" id="geometrical" value="geometrical"/>geometrical
<br/>
<input type="radio" name="paintRbn" id="classical" value="classical"/>classical
<br/>
</div
我想做:当我选择颜色复选框时,我从颜色中重新过滤。我只看了许多窗帘,只选择了颜色。在那之后,我可以选择油漆复选框,这个过滤器将在回收的窗帘中寻找。我写了这段代码:
$(function() {
var firstRun = true;
$('input').change(function() {
var category = $(this).val();
if (firstRun==true) {
$('.color').hide();
firstRun = false;
}
if($('#filterColor input:checked') !=0) {
this.checked ? $('.' + category).show() : $('.' + category).hide();
if ($('#searchPaint input:checked') !=0){
this.checked ? $('.' + category).show() : $('.' + category).hide();
}
}
if ($('#filterColor input:checked').length == 0 && $('#searchPaint input:checked').length == 0) {
$('.color').show();
firstRun = true;
}
});
});
但是这个代码在所有网页上寻找而不是在彩色滤镜中。 你能帮我理解如何制作一个有效的代码吗?