CSS ->
.chkbox-container{
float:left;
width:95px;
border:1px solid #ccc;
}
.img-container{
float:left;
width:300px;
border:1px solid #ccc;
}
img{
display:inline-block;
width:90px;
height:75px;
padding:2px;
border:1px solid black;
display:none;
}
jQuery ->
$('.chkbox-container :radio').on('change', function(){
var me = $(this);
$.each($('.img-container img'), function(i,v){
var theCats = $(v).attr('rel');
theCats = theCats.split(' ');
if($.inArray(me.val(), theCats)){
$(v).show();
}else{
$(v).hide();
}
});
});
HTML ->
<div class="chkbox-container">
<input type="radio" name="catfilter[]" value="all" checked="checked"/> All<br/>
<input type="radio" name="catfilter[]" value="category1" /> Category 1<br/>
<input type="radio" name="catfilter[]" value="category2" /> Category 2<br/>
<input type="radio" name="catfilter[]"value="category3" /> Category 3<br/>
</div>
<div class="img-container">
<img src="path.to/the/image/ext" rel="category1" />
<img src="path.to/the/image/ext" rel="category2" />
<img src="path.to/the/image/ext" rel="category3" />
</div>
为任何发现它有用的人工作 jsFiddle。