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?
New contributor
Sergei Shumailov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.