JSFiddle - React, Tailwind, and code Playground

by chayacooper

HTML

<div id="container">    
    <ul id="filterStyleOptions" class="filterOptions">
        <li class="active"><a href="#" data-style="All">All Styles</a></li>        
        <li><a href="#" data-style="Crew Neck">Crew Neck</a></li>
        <li><a href="#" data-style="V-Neck">V-Neck</a></li>
        <li><a href="#" data-style="Long Sleeves">Long Sleeves</a></li>
        <li><a href="#" data-style="Short Sleeves">Short Sleeves</a></li>   
        <li><a href="#" data-style="Sleeveless">Sleeveless</a></li>           
  </ul>
    
    <ul id="content">
      <li data-style="Long Sleeves, V-Neck" data-color="Black">Item 1</li>       
      <li data-style="Crew Neck, Short Sleeves" data-color="Blue, Red">Item 2</li>     
      <li data-style="Sleeveless, V-Neck" data-color="Black & White">Item 3</li>      
      <li data-style="Crew Neck" data-color="Black">Item 4</li>       
      <li data-style="V-Neck" data-color="Black">Item 5</li>       
      <li data-style="Short Sleeves" data-color="Red">Item 6</li>     
      <li data-style="Sleeveless" data-color="Black">Item 7</li>  
    </ul>
</div>

CSS

ol, ul {
    list-style: none;
}
ul.filterOptions {
    height: 52px;
    margin: 10px 0;
    overflow: hidden;
}
ul.filterOptions li {
    height: 52px;
    margin-right: 2px;
    float: left;
}
ul.filterOptions li a {
    height: 50px;
    padding: 0 10px;
    border: 1px solid #999;
    background: #cfcfcf;
    color: #fff;
    font-weight: bold;
    line-height: 50px;
    text-decoration: none;
    display: block;
}
ul.filterOptions li a:hover {
    background: #c9c9c9;
}
ul.filterOptions li.active a {
    background: #999;
}

JavaScript

$(document).ready(function () {    
        $('#filterStyleOptions li a').click(function () {
            var attrStyle = $(this).data('style');
            $('#filterStyleOptions li').removeClass('active');
            $(this).parent().addClass('active');
            if (attrStyle == 'All') {
                $('#content').find('li').show();
            } else {
                $('#content').find('li:not([data-style="' + attrStyle + '"])').hide();
                $('#content').find('li[data-style="' + attrStyle + '"]').show();
            }
            return false;
        });
});