I have lots of divs, all with the class product_listing
. They all have a data-category
property, which is either accessory
, hardware
, mobile
, or software
. In my javascript, I want to only show the ones with the checkbox for their category checked. My checkboxes in the html are coded as:
<input type="checkbox" name="category_filter" value="all"
checked="checked"> All</input><br />
<input type="checkbox" name="category_filter"
value="accessory"> Accessory<br />
<input type="checkbox" name="category_filter"
value="hardware"> Hardware<br />
<input type="checkbox" name="category_filter" value="mobile"> Mobile
App<br />
<input type="checkbox" name="category_filter"
value="software"> Software<br />
In my javascript I have the arrays accessory_products
, hardware_products
, mobile_products
, and software_products
, so I just need to show and hide them based on checked boxes. I just don't know how to make the if statements to check which boxes are checked. Can anyone help? I'm using jquery, of course.