How to filter a number of divs based on what they have in their custom data attribute using jQuery? The problem is that the attribute can have more than 1 values (which is treated as 1 string). So I need to work out if the data-att value contains a string.
<a href="">small</a>
<a href="">medium</a>
<a href="">large</a>
<div class="size" data-size="small">small tee</div>
<div class="size" data-size="small medium">small tee</div>
<div class="size" data-size="small medium">small tee</div>
<div class="size" data-size="small">small tee</div>
<div class="size" data-size="medium large">small tee</div>
<div class="size" data-size="medium large">small tee</div>
So if small link is clicked it should show only the divs whose data-size value contains small, so 'small' and 'small medium'.
I've tried:
$("a").click(function(e) {
    var selectSize = $(this).text();
    filter(selectSize)
            e.preventDefault();
});
function filter(e){
$('.tyre').hide()
    .filter('[data-sizes=""]:contains(' + e + ')')
    .show(); // show the filtered elements
}
but no go.
 
     
     
     
     
     
    