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 7875245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:57:01+00:00 2026-06-03T02:57:01+00:00

UPDATE: Jared’s answer was the solution – here is my code, where I just

  • 0

UPDATE:
Jared’s answer was the solution – here is my code, where I just added the else statement to perform the hide/show of the list items if indeed there were a matching set.

$(document).ready(function() {
$("form#filterForm").submit(function () {
    var type = $("select#typeList option:selected").val();
    var style = $("select#styleList option:selected").val();
    var items = $(".container .content ul li").filter('.' + type + '.' + style);

    if (!items.length) {
        alert('no items...');
        return false;
    } else {

   $(".container .content ul li").hide();
 $(".container .content ul li"+type+style).show();
 mCustomScrollbars();
 return false;
    }

});
}); 

end update.
I have some code working but I am having trouble taking it to the final step. I have a list of thumbnails in an unordered list.

<div class="content">
            <ul>
            <li class="portfolio_images type-portfolio_images category-commercial category-traditional"><img src="thumb_test-image1.jpg" /></li><li class="portfolio_images category-residential category-contemporary"><img src="thumb_test-image2.jpg" /></li><li class="portfolio_images type-portfolio_images category-commercial category-contemporary"><img src="thumb_test-image3.jpg" /></li><li class="portfolio_images type-portfolio_images category-commercial" ><img src="res1-2-THUMB.jpg" /></li><li class="portfolio_images type-portfolio_images category-interior-design"><img src="res1-2-THUMB.jpg" /></li><li class="portfolio_images type-portfolio_images category-interior-design"><img src="res3-3-THUMB.jpg" /></li><li class="portfolio_images type-portfolio_images category-residential category-contemporary" ><img src="thumb_test-image2.jpg" /></li><li class="portfolio_images type-portfolio_images category-commercial category-traditional"><img src="thumb_test-image1.jpg" /></li><li class="portfolio_images type-portfolio_images category-interior-design" ><img src="res1-2-THUMB.jpg" /></li><li class="portfolio_images type-portfolio_images category-commercial category-contemporary"><img src="thumb_test-image3.jpg" /></li><li class="portfolio_images type-portfolio_images category-interior-design"><img src="res1-2-THUMB.jpg" /></li>
            </ul>
        </div>

Each list-item will have multiple categories. I have a form with 2 select fields, and I am using jQuery to get the value of the select fields, which correspond to the classNames in the list-items – these are set as variables and used to show and hide the list-items accordingly.

 <form id="filterForm" action="">
<select id="typeList" name="typeList">
<option value=".portfolio_images">All</option>
<option value=".category-commercial">category-commercial</option>
<option value=".category-residential">category-residential</option>
</select>

<select id="styleList" name="typeList">
<option value=".type-portfolio_images">All</option>
<option value=".category-traditional">category-traditional</option>
<option value=".category-contemporary">category-contemporary</option>
</select>
<input id="submit_btn" type="submit" value="submit" label="submit" />   </form>  

<script>
$(document).ready(function() {
$("form#filterForm").submit(function () {
var $selectTypeClass=$("select#typeList option:selected").val();
var $selectStyleClass=$("select#styleList option:selected").val();
$(".container .content ul li").not($selectTypeClass+$selectStyleClass).hide();
$(".container .content ul li"+$selectTypeClass+$selectStyleClass).show();
mCustomScrollbars();
return false;
});
});
 </script>  

This works really well. However, I have some cases where an item will have one category, but not the other: for example, it may have ‘category-traditional’ but NOT ‘category-residential’. So what I am looking to do, is test or check to see is there are NO items that match both selected classes, to show an alert message (“none of the items matched both selections, etc”). Otherwise, if there are any that match both, go ahead and perform the function as normal.

I am having a world of trouble because I tried using each() to test, but that didn’t work because it would loop through the list and always return the alert – because it basically stops on the first

  • in the list that doesn’t match and then breaks out of the loop.

    So how would I go about setting it up to check if NONE of the items match both selected classes? Would I have to index the whole set somehow and check it as a whole, as opposed to the iteration that occurs with each() ? Stumped here – any help, I thank you 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-06-03T02:57:02+00:00Added an answer on June 3, 2026 at 2:57 am

      You can use multiple classes in CSS (and Sizzle) selectors like .class1.class2. Just search for elements specifically with both classes and test the length:

      $(document).ready(function() {
         $("form#filterForm").submit(function () {
              var type = $("select#typeList option:selected").val();
              var style = $("select#styleList option:selected").val();
              var items = $(".container .content ul li").filter('.' + type + '.' + style);
      
              if (!items.length) {
                  alert('no items...');
              }
          });
      }); 
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    UPDATE: I've build a WPF app with no code behind, just put in a
    [UPDATE] Was just an idiot mistake. See end for solution. I am trying to
    Update: Solved, with code I got it working, see my answer below for the
    UPDATE : The full site code is here - https://github.com/eWizardII/PeerInstruction I have the following
    Update In the wiki spirit of StackOverflow, here's an update: I spiked Joe White's
    UPDATE!!! Suggested answer is NOT correct, my mistake. The #container DIV should've had float:left;.
    UPDATE: Thanks for all your help guys! I just need to take a litte
    Update 2: thanks again to @deepak-azad, I managed to solve my problem : here
    UPDATE: Solution at bottom. I recently switched from using a set up such as
    UPDATE: I added this to my unload function: $(window).resize(function(){ var pageheight = $(window).height(); $('section').css('height',

    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.