Jquery multiple checkbox filtering

后端 未结 2 1687
春和景丽
春和景丽 2020-12-10 22:16

I have three sets of checkboxes which allow me to filter a number of divs based on data attributes. This works great but not as I need it to.

If you visit the jsfidd

2条回答
  •  旧巷少年郎
    2020-12-10 22:24

    You should hide the elements before you filter them and show them after, add a .hide() before the .filter(selector). Like so:

    $('.flowers > div').hide().filter(selector).show(); 
    

    This should hide all of the elements, then show the selected elements.

    DEMO

提交回复
热议问题