0
votes

World!

I need help refining the concept for a JQuery gallery with two filters.

Right now, my logic/approach is to use the filters as class names & ids. So, when someone clicks a filterable 'button' with an id, it will trigger an action to be taken on all associated classes. Now, I can filter each and it works good. BUT, when I select a filter from 1 AND 2, I want it to rule-out all other cards, even if they belong to one of the two filters. Only if the card belongs to BOTH filters should it show. Right now, even if it only belongs to one filter it shows.

In regards to selecting multiple elements at one time, I can't wrap my mind around it. I am confused how to "reduce" this code. If you have a great idea to help reduce the code, please share. I am still learning JQuery.

I am trying to design & build a webpage that features a JQuery gallery of div containers. I am calling these div containers, "cards". Each card stores a title, a blurb, etc... The user can browse cards by filtering the cards by category (competency) and day of the week. This will help the user pick the best card for them.

Right now, I manually write each case for the filter. It's probably not the most efficient way of writing this, but hey, it works! BUT, when I select a filter from 1 AND 2, I want it to rule-out all other cards, even if they belong to one of the two filters. Only if the card belongs to BOTH filters should it show. Right now, even if it only belongs to one filter it shows.

Also, I am building the page with Bootsrap.

HTML 2 Filter Setup

<!-- First Filter, by Category -->
    <div class="col-md-2 col-sm-2 col-xs-2">
      <img id="buttonAll" src="..."/>
    </div>
    <div class="col-md-2 col-sm-2 col-xs-2">
      <img id="button1" src="..."/>
    </div>
    <div class="col-md-2 col-sm-2 col-xs-2">
      <img id="button2" src="..."/>
    </div>
    <div class="col-md-2 col-sm-2 col-xs-2">
      <img id="button3" src="..."/>
    </div>
    <div class="col-md-2 col-sm-2 col-xs-2">
      <img id="button4" src="..."/>
    </div>

<!-- Second Filter, by Day -->    
      <p id="dayAll">Any Day</p>
      <p id="monday">Monday</p>
      <p id="tuesday">Monday</p>
      <p id="wednesday">Wednesday</p>
      <p id="thursday">Thursday</p>
      <p id="friday">Friday</p>

HTML Card / Gallery setup

<div class="container">
  <div class="row">
    <!-- START CLASS CARD -->
            <div class="class-card sort-button1 sort-button2 sort-button3 sort-button4 monday">
                <h1>Class Title</h1>
                <h3>Monday @ 3:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_1.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_3.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_4.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->


   <!-- START CLASS CARD -->
            <div class="class-card sort-button2 monday">
                <h1>Class Title</h1>
                <h3>Monday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->

      <!-- plus a bunch more cards -->

  </div><!-- end row -->
</div><!-- end container -->

JS The filter 1, in effect

// Filter 1: by Day

// Show cards for all days of week by default
$('.monday').show();
$('.tuesday').show();
$('.wednesday').show();
$('.thursday').show();
$('.friday').show();
// When user clicks "View All" show cards for all days of week
$('#dayAll').click(function() {
    $('.monday').fadeIn();
    $('.tuesday').fadeIn();
    $('.wednesday').fadeIn();
    $('.thursday').fadeIn();
    $('.friday').fadeIn();
    $('.monday').fadeIn();
});
// When user clicks "Monday" show cards for Monday and hide others
$('#monday').click(function() {
    $('.tuesday').fadeOut();
    $('.wednesday').fadeOut();
    $('.thursday').fadeOut();
    $('.friday').fadeOut();
    $('.monday').fadeIn();
});
// When user clicks "Tuesday" show cards for Tuesday and hide others
$('#tuesday').click(function() {
    $('.monday').fadeOut();
    $('.tuesday').fadeIn();
    $('.wednesday').fadeOut();
    $('.thursday').fadeOut();
    $('.friday').fadeOut();
});
// When user clicks "Wednesday" show cards for Wednesday and hide others
$('#wednesday').click(function() {
    $('.monday').fadeOut();
    $('.tuesday').fadeOut();
    $('.wednesday').fadeIn();
    $('.thursday').fadeOut();
    $('.friday').fadeOut();
});
// When user clicks "Thursday" show cards for Thursday and hide others
$('#thursday').click(function() {
    $('.monday').fadeOut();
    $('.tuesday').fadeOut();
    $('.wednesday').fadeOut();
    $('.thursday').fadeIn();
    $('.friday').fadeOut();
});
// When user clicks "Friday" show cards for Friday and hide others
$('#friday').click(function() {
    $('.monday').fadeOut();
    $('.tuesday').fadeOut();
    $('.wednesday').fadeOut();
    $('.thursday').fadeOut();
    $('.friday').fadeIn();
});

JS The filter 2, in effect

// Filter 2: by Category (Competency) 

// Show cards for all categories by default
$('.sort-button1').show();
$('.sort-button2').show();
$('.sort-button3').show();
$('.sort-button4').show();
// When user clicks "View All" show cards for all categories
$('#buttonAll').click(function() {
    $('.sort-button1').fadeIn();
    $('.sort-button2').fadeIn();
    $('.sort-button3').fadeIn();
    $('.sort-button4').fadeIn();
});
// When user clicks "button1" show cards for button1 and hide others
$('#button1').click(function() {
    $('.sort-button2').fadeOut();
    $('.sort-button3').fadeOut();
    $('.sort-button4').fadeOut();
    $('.sort-button1').fadeIn();
});
// When user clicks "button2" show cards for button2 and hide others
$('#button2').click(function() {
    $('.sort-button1').fadeOut();
    $('.sort-button3').fadeOut();
    $('.sort-button4').fadeOut();
    $('.sort-button2').fadeIn();
});
// When user clicks "button3" show cards for button3 and hide others
$('#button3').click(function() {
    $('.sort-button1').fadeOut();
    $('.sort-button2').fadeOut();
    $('.sort-button4').fadeOut();
    $('.sort-button3').fadeIn();
});
// When user clicks "button4" show cards for button4 and hide others
$('#button4').click(function() {
    $('.sort-button1').fadeOut();
    $('.sort-button2').fadeOut();
    $('.sort-button3').fadeOut();
    $('.sort-button4').fadeIn();
});

See the full project on CodePen.

I am still a beginner JQuery programmer, so, I can't fit all of my code in this article. Can you please look at my CodePen and view the rest of it?

You might laugh at what I have written for the JS part, because I wrote out step-by-step, no loops or variables. If this can be improved, I am open as well. The loops and variable just confuse me at this point. Thank you!!

2
Also just at a glance, a quick note. show and fadeOut are jQuery methods. If you do not put () on the end of them to execute them, simply doing $(selector).show or $(selector).fadeOut will do nothing.Taplar
Quite a bit of this could be reduced. For instance, in the cases where you have a group of things and you are hiding all the other things, and showing one thing, if you give them a common class, in addition to whatever classes they already have, you can select on that common class, hide all of them, and then show the specific one you want to show. Rather than targeting each one for hiding.Taplar
Or if you don't want to go that route, you can select multiple elements at one time, such as $('.sort-button-1, .sort-button-2').fadeOut(). You can comma separate the different selectors in the string for a logical OR.Taplar
Hello, @Taplar thank you for the wisdom! I have corrected the missing "()" characters. Now, I can filter each and it works good. BUT, what if I select a filter from 1 AND 2? I want it to rule-out all other cards, even if they belong to one of the two filters. Only if the card belongs to BOTH filters should it show. Right now, even if it only belongs to one filter it shows. Maybe, this is what you explained with your last comment? In regards to selecting multiple elements at one time, but I can't wrap my mind around it. Can you show an example of this case? Thank You, @Taplar!Matie
Also, I am completely confused on how to "reduce" the code. The only way I have confidence to execute this from concept to completion is how I've done here. Please propose the reduced technique, as I can't visualize it now. Thank you @TaplarMatie

2 Answers

1
votes

Alright, so I've made various changes to your logic.

First off take a look at your options. All your category options have a class="categoryFilter" on them. This makes it easy to select them all. They also have a data-target on them which has as it's value the class that the option should sort on. The all categories also has one, but it is blank.

Next if you take a look at your day options, they also have a class="dayFilter" on them and also a data-target with the class they should filter on.

Now take a look at the logic. The first thing we do is get a reference to all your cards and cache it in a variable. We do the same for all our day filters and category filters.

We then show all the cards as you were before.

Then, we create bindings for the category and day filters. When any of the filters are clicked, we put the selected class on the filter clicked, and remove it from all the other related filters. Once we do that, we then call the filterCards method which is used by both filter event handlers.

The first thing this method does is shows all the cards, to reset any filtering we might have done previously.

We then get the dayFilter and categoryFilter that were previously selected. If we find them, we take their data-target (which has the class that should be filtered on) and push it to an array with the leading . to signify that it is a class selector.

Then we check if the array has elements in it. If it does, then we find any element that does not match our filters. The joining of the array makes it so that if you selected a day and category filter that the selector will be the two selectors joined, such as .monday.sort-button2, which for a selector says the element has to have both of those classes.

Finding elements that do not have the matching class(es), we hide them, accomplishing our combined filter.

I did not include the logic you had in your codepen for changing the opacity of some of the filter options, but this should demonstrate one approach for implementing a combined filter.

// Filter Buttons

var $cards = $('.class-card');
var $dayFilters = $('.dayFilter');
var $categoryFilters = $('.categoryFilter');
var $noResults = $('#noResults');

// Show all days on page load 
$cards.show();
// Hide the no results message
$noResults.hide();

$categoryFilters.on('click', function(e){
  var $category = $(e.target);
  
  $categoryFilters.removeClass('selected');
  $category.addClass('selected')
  
  filterCards();
});

$dayFilters.on('click', function(e){
  var $day = $(e.target);
  
  $dayFilters.removeClass('selected');
  $day.addClass('selected')
  
  filterCards();
});

function filterCards () {
  $cards.show();
  $noResults.hide();
  
  var $day = $dayFilters.filter('.selected');
  var $category = $categoryFilters.filter('.selected');
  var filterClasses = [];
  
  if ($day.length) filterClasses.push('.'+ $day.data('target'));
  if ($category.length) filterClasses.push('.'+ $category.data('target'));
  
  if (filterClasses) {
      var filter = filterClasses.join('');
      
      $cards.not(filter).hide();
      
      if (!$cards.filter(filter).length) {
        $noResults.show();
      }
      
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- 3RD PARTY PLUG-INS --> 
    <!-- BOOTSRAP CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- TOUR CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.11.0/css/bootstrap-tour.css">
    <!-- SLIDER CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightslider/1.1.6/css/lightslider.css">
    <!-- LIGHTBOX CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.0.47/jquery.fancybox.min.css">


<!-- IN-HOUSE PLUG-INS -->
    <!-- DAILY DOSE THUMBNAIL: MAIN CSS -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/26p04xz6frwy51fbt3d0kby8d55eisde.css">
    <!-- DAILY DOSE THUMBNAIL: MOBILE BREAKPOINTS CSS -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/7x469uo9iofg276dm79yduzj1vujjj08.css">
    <!-- CSOD Overrides -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/8zp03gs0o59gz43i4gr33i4nhwp6h719.css">
    <!-- LightSlider Overrides -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/aminxarvz1xsrkp21p470kz3tyanwcpe.css">
	  <!-- Core CSS Styles -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/uwonou0jrd00r7q8or538r8a92jwpusp.css">


<span class="space-6"></span>
    


	<div class="container">
        <div class="row">
        	<img width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Oldies_But_Goodies.jpg"/> 
        </div><!-- end row -->
    </div><!-- end container -->

	<span class="space-6"></span>


	<div class="container">
        <div class="row">
        	<img width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Browse_Courses_by_Competency_V2.jpg"/> 
        </div><!-- end row -->
    </div><!-- end container -->
    
    
    
	<span class="space-6"></span>


	<div class="container">
    	<div class="row">
        	<div class="col-md-offset-2 col-md-8">
            	<div class="row">
                    <div class="col-md-offset-1 col-md-2 col-sm-offset-1 col-sm-2 col-xs-offset-1 col-xs-2">
                        <img id="buttonAll" class="categoryFilter" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_ALL_ACTIVE.jpg" data-target="" /> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button1" class="categoryFilter" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_IT_ACTIVE_V2.jpg" data-target="sort-button1"/> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button2" class="categoryFilter" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_DR_ACTIVE.jpg" data-target="sort-button2"/> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button3" class="categoryFilter" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_FOP_ACTIVE_V2.jpg" data-target="sort-button3"/> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button4" class="categoryFilter" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_BYBS_ACTIVE.jpg" data-target="sort-button4"/> 
                    </div>
                </div><!-- end row -->
            </div><!-- end col-md-offset-2 col-md-8 -->
        </div><!-- end row -->
    </div><!-- end container -->
    
    

	
    <span class="space-6"></span>
    
    
    

	<div class="container">
    	<div class="row">
        	<h2 class="text-center">And by day:</h2>
        </div><!-- end row -->
        
        
        <span class="space-6"></span>
        
        
        <div class="day-menu row text-center">
            <p id="dayAll" class="dayFilter" data-target="">Any Day</p>
            <p id="monday" class="dayFilter" data-target="monday">Monday</p>
            <p id="tuesday" class="dayFilter" data-target="tuesday">Tuesday</p>
            <p id="wednesday" class="dayFilter" data-target="wednesday">Wednesday</p>
            <p id="thursday" class="dayFilter" data-target="thursday">Thursday</p>
            <p id="friday" class="dayFilter" data-target="friday">Friday</p>
        </div><!-- end row -->
    </div><!-- end container -->
        
    
    
    <span class="space-6"></span>


    <div class="container">
        <div class="row">
        
        	<!-- START CLASS CARD -->
            <div class="class-card sort-button1 sort-button2 sort-button3 sort-button4 monday">
                <h1>Class Title</h1>
                <h3>Monday @ 3:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_1.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_3.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_4.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 monday">
                <h1>Class Title</h1>
                <h3>Monday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 sort-button3 tuesday">
                <h1>Class Title</h1>
                <h3>Tuesday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_3.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button4 wednesday">
                <h1>Class Title</h1>
                <h3>Wednesday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_4.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button1 sort-button4 thursday">
                <h1>Class Title</h1>
                <h3>Thursday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_1.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_4.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button1 friday">
                <h1>Class Title</h1>
                <h3>Friday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_1.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 thursday">
                <h1>Class Title</h1>
                <h3>Thursday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 wednesday">
                <h1>Class Title</h1>
                <h3>Wednesday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
        </div><!-- end row -->    
    </div><!-- end container -->
    

<div id="noResults" style="display:none">
  No classes that day.  Try another day!
</div>


  
<!-- JQUERY JS -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- BOOTSRAP JS -->
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- TOUR JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.11.0/js/bootstrap-tour.js"></script>
<!-- SLIDER JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lightslider/1.1.6/js/lightslider.js"></script> 
<!-- FANCY BOX JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.0.47/jquery.fancybox.min.js"></script>
0
votes

Is this what you want?

// Filter Buttons

var filters = [];

$(".competency-menu img").on('click', function(){
    $(".competency-menu img").addClass('PASSIVE').removeClass('ACTIVE');
    $(this).removeClass('PASSIVE').addClass('ACTIVE');
    filters[0] = $(this).data('filter');
    applyFilter(filters);
});

$(".day-menu > p").on('click', function(){
    $(".day-menu > p").addClass('PASSIVE').removeClass('ACTIVE');
    $(this).removeClass('PASSIVE').addClass('ACTIVE');
    filters[1] = $(this).data('filter');
    applyFilter(filters);
});

function applyFilter(filter){
  $(".class-card").fadeOut();
  if(filter[0] && filter[1]){
    $("." + filter[0] + "." + filter[1]).fadeIn();
  } else if (filter[0]){
    $("." + filter[0]).fadeIn();
  } else if (filter[1]){
    $("." + filter[1]).fadeIn();
  } else {
    $(".class-card").fadeIn();
  }
}
.ACTIVE {
	opacity: 1.0;	
}
.PASSIVE {
	opacity:.45;	
}
.class-card {
    padding: 30px;
    border: 1px #d6d6d6 solid;
    border-radius: 5px;
    width: 30%;
    margin: 15px;
    float: left;
}
.class-card h1 {
    font-family: "Times New Roman", Times, serif;
    font-weight:bold;
}
.class-card p {
    font-size:14px;
    line-height:18.27px;
    margin-top:10px;
}
.class-card ul li {
   margin:9px 0px 0px 15px;
   color:#6f7179;
}
.space-6 {
	height:32px;
	display:block;	
}
.day-menu p {
    display: inline-block;
    padding: 10px;
    text-transform: uppercase;
    font-size: 14px;
    color: #c1c1c1;
    letter-spacing: 1;
}
<!-- 3RD PARTY PLUG-INS --> 
    <!-- BOOTSRAP CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- TOUR CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.11.0/css/bootstrap-tour.css">
    <!-- SLIDER CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightslider/1.1.6/css/lightslider.css">
    <!-- LIGHTBOX CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.0.47/jquery.fancybox.min.css">


<!-- IN-HOUSE PLUG-INS -->
    <!-- DAILY DOSE THUMBNAIL: MAIN CSS -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/26p04xz6frwy51fbt3d0kby8d55eisde.css">
    <!-- DAILY DOSE THUMBNAIL: MOBILE BREAKPOINTS CSS -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/7x469uo9iofg276dm79yduzj1vujjj08.css">
    <!-- CSOD Overrides -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/8zp03gs0o59gz43i4gr33i4nhwp6h719.css">
    <!-- LightSlider Overrides -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/aminxarvz1xsrkp21p470kz3tyanwcpe.css">
	  <!-- Core CSS Styles -->
    <link rel="stylesheet" href="https://sephora.box.com/shared/static/uwonou0jrd00r7q8or538r8a92jwpusp.css">


<span class="space-6"></span>
    


	<div class="container">
        <div class="row">
        	<img width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Oldies_But_Goodies.jpg"/> 
        </div><!-- end row -->
    </div><!-- end container -->

	<span class="space-6"></span>


	<div class="container">
        <div class="row">
        	<img width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Browse_Courses_by_Competency_V2.jpg"/> 
        </div><!-- end row -->
    </div><!-- end container -->
    
    
    
	<span class="space-6"></span>


	<div class="container">
    	<div class="row">
        	<div class="col-md-offset-2 col-md-8">
            	<div class="row competency-menu">
                    <div class="col-md-offset-1 col-md-2 col-sm-offset-1 col-sm-2 col-xs-offset-1 col-xs-2">
                        <img id="buttonAll" data-filter="" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_ALL_ACTIVE.jpg"/> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button1" data-filter="sort-button1" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_IT_ACTIVE_V2.jpg"/> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button2" data-filter="sort-button2" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_DR_ACTIVE.jpg"/> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button3" data-filter="sort-button3" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_FOP_ACTIVE_V2.jpg"/> 
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-2">
                        <img id="button4" data-filter="sort-button4" width="100%" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Buttons_BYBS_ACTIVE.jpg"/> 
                    </div>
                </div><!-- end row -->
            </div><!-- end col-md-offset-2 col-md-8 -->
        </div><!-- end row -->
    </div><!-- end container -->
    
    

	
    <span class="space-6"></span>
    
    
    

	<div class="container">
    	<div class="row">
        	<h2 class="text-center">And by day:</h2>
        </div><!-- end row -->
        
        
        <span class="space-6"></span>
        
        
        <div class="day-menu row text-center">
            <p id="dayAll" data-filter="">Any Day</p>
            <p id="monday" data-filter="monday">Monday</p>
            <p id="tuesday" data-filter="tuesday">Tuesday</p>
            <p id="wednesday" data-filter="wednesday">Wednesday</p>
            <p id="thursday" data-filter="thursday">Thursday</p>
            <p id="friday" data-filter="friday">Friday</p>
        </div><!-- end row -->
    </div><!-- end container -->
        
    
    
    <span class="space-6"></span>


    <div class="container">
        <div class="row">
        
        	<!-- START CLASS CARD -->
            <div class="class-card sort-button1 sort-button2 sort-button3 sort-button4 monday">
                <h1>Class Title</h1>
                <h3>Monday @ 3:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_1.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_3.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_4.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 monday">
                <h1>Class Title</h1>
                <h3>Monday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 sort-button3 tuesday">
                <h1>Class Title</h1>
                <h3>Tuesday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_3.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button4 wednesday">
                <h1>Class Title</h1>
                <h3>Wednesday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_4.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button1 sort-button4 thursday">
                <h1>Class Title</h1>
                <h3>Thursday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_1.jpg"/>
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_4.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button1 friday">
                <h1>Class Title</h1>
                <h3>Friday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_1.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 thursday">
                <h1>Class Title</h1>
                <h3>Thursday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            <!-- START CLASS CARD -->
            <div class="class-card sort-button2 wednesday">
                <h1>Class Title</h1>
                <h3>Wednesday @ 12:00 PM</h3>
                <p>Develops:
                    <img class="tiny-button" src="https://sephora.csod.com/clientimg/sephora/welcome/20180106_Careerfest_Button_Tiny_2.jpg"/>
                </p>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tristique placerat erat, ut varius quam pulvinar eget. Ut mollis quam at maximus vulputate. Suspendisse posuere turpis eu accumsan tempor. Donec ac tortor vitae libero hendrerit porttitor. Cras id vulputate turpis, ac tincidunt ante. Integer enim nulla, bibendum ut porta vel, pharetra id libero.</p>
                <ul>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit</li>
                </ul>
                <p>Hosted by: <strong>Mind Gym</strong></p>
            </div><!-- end class-card -->
            
            
            
            
        </div><!-- end row -->    
    </div><!-- end container -->
    




  
<!-- JQUERY JS -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- BOOTSRAP JS -->
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- TOUR JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.11.0/js/bootstrap-tour.js"></script>
<!-- SLIDER JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lightslider/1.1.6/js/lightslider.js"></script> 
<!-- FANCY BOX JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.0.47/jquery.fancybox.min.js"></script>