Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <fieldset>
- <div class="col-md-6 test-one"><label><input id="example-category-1" type="checkbox" value="first-checkbox" />CHOOSE CATEGORY 1</label></div>
- <div class="col-md-6 test-one"><label><input id="example-category-2" type="checkbox" value="second-checkbox" />CHOOSE CATEGORY 2</label></div>
- </fieldset>
- var test = true;
- $(".test-one").change(function() {
- if(test){
- $('div[data-product]').parents("li").hide();
- //hide every product after first click on any checkbox
- if( $('#example-category-1').is(':checked') ) {
- //check for checkbox activation and show products if true
- $('div[data-product="1802"]').parents("li").show();
- $('div[data-product="1781"]').parents("li").show();
- }
- if( $('#category-2').is(':checked') ) {
- //check for checkbox activation and show products if true
- $('div[data-product="1348"]').parents("li").show();
- $('div[data-product="1347"]').parents("li").show();
- }
- test =false;
- //set to false so we don't enter this if statement again
- }
- });
- $('#example-category-1').click(function() {
- if( $(this).is(':checked') ) {
- $('div[data-product="1802"]').parents("li").show();
- $('div[data-product="1781"]').parents("li").show();
- } else {
- $('div[data-product="1802"]').parents("li").hide();
- $('div[data-product="1781"]').parents("li").hide();
- }
- });
- $('#example-category-2').click(function() {
- if( $(this).is(':checked') ) {
- $('div[data-product="1348"]').parents("li").show();
- $('div[data-product="1347"]').parents("li").show();
- } else {
- $('div[data-product="1348"]').parents("li").hide();
- $('div[data-product="1347"]').parents("li").hide();
- }
- });
Add Comment
Please, Sign In to add comment