I'm trying to make filter from several divs:
<div class="sgmt" data-id="orange, apple">First one</div> <div class="sgmt" data-id="onion, apple">Second one</div> <div class="sgmt" data-id="onion, grape">Third one</div><script> $param="orange";$('.sgmt').filter(function() { if ($param == '0') { return '*'; } else { return $(this).data('view') == $param; } }).addClass("sgmt-show"); </script>
But, it's not working with several params inside data-id, what I'm doing wrong?