我想用jquery或javascript过滤这个简单的LIST。 我找到的唯一例子是多个选定框,如下所示:http://jsfiddle.net/EfEYQ/
你能帮帮我吗? Thx提前<select id="filtercountry">
<option value='ALL' selected="selected">Select by Country</option>
<option value="1">Australia</option>
<option value="2">Austria</option>
<option value="3">Brazil</option>
<option value="4">Canada</option>
</select>
<ul class="submenu">
<li class="submenucategory">KIDS</li>
<li id="Cell1" class="lilist">AAAAAA <span class="country">1</span></li>
<li id="Cell2" class="lilist">BBBBBB <span class="country">2</span></li>
<li id="Cell3" class="lilist">CCCCCC <span class="country">2</span></li>
<li id="Cell4" class="lilist">DDDDDD <span class="country">1</span></li>
<li id="Cell5" class="lilist">EEEEEE <span class="country">3</span></li>
<li id="Cell6" class="lilist">FFFFFF <span class="country">4</span></li>
</ul>
答案 0 :(得分:3)
你去,交配 - 几乎与上面的例子相同:
$('#filtercountry').change(function(){
var criteria = $(this).val();
if(criteria == 'ALL'){
$('.lilist').show();
return;
}
$('.country').each(function(i,option){
if($(this).html() == criteria){
$(this).parent().show();
}else {
$(this).parent().hide();
}
});
});