JSFiddle - React, Tailwind, and code Playground

by Mitsuru Katoh

HTML

<div id="search">
    <ul id="attribute">
        <li><label class="selected"><input type="checkbox" id="all_attribute" class="sort" checked="checked">すべて</label></li>
        <li><label><input type="checkbox" id="attribute01" class="sort">attribute01</label></li>
        <li><label><input type="checkbox" id="attribute02" class="sort">attribute02</label></li>
        <li><label><input type="checkbox" id="attribute03" class="sort">attribute03</label></li>
        <li><label><input type="checkbox" id="attribute04" class="sort">attribute04</label></li>
        <li><label><input type="checkbox" id="attribute05" class="sort">attribute05</label></li>
    </ul>

    <ul id="type">
        <li><label class="selected"><input type="checkbox" id="all_type" class="sort" checked="checked">すべて</label></li>
        <li><label><input type="checkbox" id="type01" class="sort">type01</label></li>
        <li><label><input type="checkbox" id="type02" class="sort">type02</label></li>
        <li><label><input type="checkbox" id="type03" class="sort">type03</label></li>
        <li><label><input type="checkbox" id="type04" class="sort">type04</label></li>
        <li><label><input type="checkbox" id="type05" class="sort">type05</label></li>
        <li><label><input type="checkbox" id="type06" class="sort">type06</label></li>
        <li><label><input type="checkbox" id="type07" class="sort">type07</label></li>
        <li><label><input type="checkbox" id="type08" class="sort">type08</label></li>
    </ul>

</div><!-- /.#search -->

<ul id="list">
    <li class="attribute01 type01"><a href="#">attribute01 type01</a></li>
    <li class="attribute03 type02"><a href="#">attribute03 type02</a></li>
    <li class="attribute02 type05"><a href="#">attribute02 type05</a></li>
    <li class="attribute05 type06"><a href="#">attribute05 type06</a></li>
    <li class="attribute03 type07"><a href="#">attribute03 type07</a></li>
    <li class="attribute04 type04"><a href="#">attribute04...

CSS

.active {
    background-color: red;
}

#search {
    overflow: hidden;
}
#search > ul {
    float: left;
}

JavaScript

$( function() {
    $( '#search li label input:not(#all_attribute)' ).click( function() {
        var inputkey = [ 'attribute', 'type' ]
          , i, l = inputkey.length
          , $res, $tmp, res = []
          , $all = $( '#all_attribute' );
          ;
        $tmp = $( '#list > li' ).removeClass( 'active' );
        for ( i = 0; i < l; i++ ) {
            res = []
            $( '#search input[id^="' + inputkey[ i ] + '"]:checked' ).each( function() {
                res.push( $( this )[ 0 ].id );
            } );
            if ( !res.length ) { continue; }
            $tmp = $( '#list > li.' + res.join( ', #list > li.' ) );
            if ( !$res || !$res.length ) {
                $res = $tmp;
            } else if ( $tmp.length ) {
                $res = $res.filter( '.' + res.join( ', .' ) );
            }
        }
        if ( $res && $res.length ) {
            $res.addClass( 'active' );
            $all.prop( 'checked', false );
        } else {
            // No Selected
            res = false;
            $all.prop( 'checked', true );
        }
    } );
    $( '#all_attribute' ).click( function() {
        if (  $( this ).prop( 'checked') === true ) {
            $( '#list > li' ).removeClass( 'active' );
            $( '#search input:checked:not(#all_attribute)' ).prop( 'checked', false );
        }
    } );
    $( '#search li label input:not(#all_type)' ).click( function() {
        var inputkey = [ 'attribute', 'type' ]
          , i, l = inputkey.length
          , $res, $tmp, res = []
          , $all = $( '#all_attribute' );
          ;
        $tmp = $( '#list > li' ).removeClass( 'active' );
        for ( i = 0; i < l; i++ ) {
            res = []
            $( '#search input[id^="' + inputkey[ i ] + '"]:checked' ).each( function() {
                res.push( $( this )[ 0 ].id );
            } );
            if ( !res.length ) { continue; }
            $tmp = $( '#list > li.' + res.join( ', #list > li.' ) );
            if ( !$res ||...