Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6089215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:04:28+00:00 2026-05-23T12:04:28+00:00

I’m using the ‘ Filtering Blocks ‘ tutorial on the CSS-Tricks website which allows

  • 0

I’m using the ‘Filtering Blocks‘ tutorial on the CSS-Tricks website which allows you to filter a list of items by category.

It’s working great on an events website I’m working on, but there is no way to display a message if there are no items in a category e.g. ‘There are no upcoming events in this category’.

The code works by matching an ID in the category navigation with a class in the main listing. ‘style=”display: none;”‘ is added to any list item which doesn’t match the user’s selected category.

Here is the category navigation markup:

<ul id="category-filter">
    <li><a href="#" id="all" class="current">VIEW ALL</a></li>
    <li><a href="#" id="arts" class="filter">Arts</a></li>
    <li><a href="#" id="conference" class="filter">Conferences</a></li>
    <li><a href="#" id="exhib" class="filter">Exhibitions</a></li>
    <li><a href="#" id="faith" class="filter">Faith</a></li>
    <li><a href="#" id="lecture" class="filter">Lectures</a></li>
    <li><a href="#" id="open" class="filter">Open days</a></li>
    <li><a href="#" id="sport" class="filter">Sport</a></li>
</ul>

Here is an example of a few events:

<ul id="events-list">
    <li class="event open">
        <h3><a href="#">Open day title</a></h3>
        <small>Date and time</small>
    </li>
    <li class="event conference">
        <h3><a href="#">Conference title</a></h3>
        <small>Date and time</small>           
    </li>
    <li class="event sport">
        <h3><a href="#">Sport title</a></h3>
        <small>Date and time</small>           
    </li>
</ul>

And finally, the jQuery code:

$(function(){

    $("#all").click(function(){
        $(".event").slideDown("fast");
        $("#category-filter a").removeClass("current");
        $(this).addClass("current");
        return false;
    });

    $(".filter").click(function(){
        var thisFilter = $(this).attr("id");
        $(".event").slideUp("fast");
        $("."+ thisFilter).slideDown("fast");
        $("#category-filter a").removeClass("current");
        $(this).addClass("current");
        return false;
    });

});

Is it possible to change or add to this code to display a ‘no events’ message when appropriate? If so, any help would be greatly appreciated as I simply don’t know where to start!

Many thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:04:28+00:00Added an answer on May 23, 2026 at 12:04 pm

    This should work:

    Add a <li> specifically for showing the no results found message:

    <li class="event noresults">
        <h3>No results</h3>
        <small>please select a different category</small>           
    </li>
    

    Change your script to:

    $(function() {
    
        // hide the noresults <li>
        $(".noresults").hide();
    
        $(".filter").click(function() {
            var thisFilter = $(this).attr("id");
            $(".event").slideUp("fast");
    
            // get a list of filtered items
            var $filteredItems = $("." + thisFilter);
    
            // if there are none, show something special
            if ($filteredItems.size() == 0) {
                // show the noresults message
                $(".noresults").slideDown("fast");
            }
            else {
                // open the filtereditems 
                $filteredItems.slideDown("fast");
            }
            $("#category-filter a").removeClass("current");
            $(this).addClass("current");
            return false;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.