Enjoy: http://jsfiddle.net/v9p5C/
Toggler buttons have a data-filter
attribute which specifies what to toggle:
<input type="button" data-filter='us' value="USA"><br>
<input type="button" data-filter='jp' value="Japanese"><br>
<input type="button" data-filter='de' value="German"><br>
<input type="button" data-filter='import' value="Import"><br>
Checkboxes have a data-tags
attribute, which is a JSON array of tags:
<input type="checkbox" data-tags='["us"]'>Cadillac<br>
<input type="checkbox" data-tags='["jp","import"]'>Mazda<br>
<input type="checkbox" data-tags='["de","import"]'>VW<br>
<input type="checkbox" data-tags='["hu","import"]'>Rába<br>
And finally some jQuery to make it work:
$(document).on('click','input[type="button"]',function(e){
var filter = $(this).data('filter');
$('input[type="checkbox"]').each(function(){
var $checkbox = $(this);
var tags = $checkbox.data('tags');
$.each( tags, function(){
if( filter == this ) $checkbox.prop("checked", !$checkbox.prop("checked"));
});
});
});