I need some help.
I need to display the product listing only when the user checks the checkbox and hides it when the user deselects the checkbox, I tried it below but it is not working as expected.
The .hiddenBlock class belongs to the product listing and the showBlock class belongs to an image that I need to display if no product is selected.
document.addEventListener('DOMContentLoaded', function () {
jQuery(function ($) {
$('.jet-checkboxes-list').click(function () {
if ($('.jet-checkboxes-list').filter(':not(:checked)')) {
$(".hiddenBlock").hide();
$(".showBlock").show();
}
if ($('.jet-checkboxes-list').filter(':checked')) {
$(".hiddenBlock").delay(3500).fadeIn(500);
$(".showBlock").hide();
}
});
});
});
Can someone help me?
Thanks.
2
Answers
try this
1st: Use
change
event for checkbox,radio input2nd: For only
this
checkbox you can useif(this.checked){ .... }else{ .... }
3rd: For multiple checkboxs/product you’ll need to use
$('.jet-checkboxes-list:checked').length