'how to exclude jQuery checkbox results
I picked up some code and it works fine, but I need one more function. If I get a result which contains A and B, the result from A only and B only should be hidden again.
$("#filters :checkbox").click(function () {
$("div").hide();
$("#filters :checkbox:checked").each(function () {
$("." + $(this).val()).show();
});
});
Solution 1:[1]
You can append a string with your selected checkbox and run them as selector.
Code:
$("#filters :checkbox").click(function () {
$("div").hide();
var mySel='';
$("#filters :checkbox:checked").each(function () {
mySel+='.'+$(this).val();
});
$(mySel).show();
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Irvin Dominin |
