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

  • SEARCH
  • Home
  • 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 495535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:36:09+00:00 2026-05-13T05:36:09+00:00

I wound up converting a table to just divs… But, in doing that, I

  • 0

I wound up converting a table to just divs… But, in doing that, I need to rewrite a function and I’m having some issues… I’ve tried to implement $(this).closest(‘div’), but it’s not doing what I thought that would do… Still reading, but if someone knows of a solution, I’d be a happy camper…

Essentially, when I click on a link, it filters the table to only display rows with a class that matches the link’s class…

This is the code, which was originally created to filter a table…

<a href="#" class="dairy">Dairy</a>
<a href="#" class="meat">Meat</a>
<a href="#" class="vegetable">Vegetable</a>

$('a').click(function(evt){
    var myId = $(this).attr('class');

    $('tr').each(function(idx, el){
        if ($(el).hasClass(myId))
        {
            $(el).show();
        }
        else
        {
            $(el).hide();
        }
    });
});

I’ve since changed the table to divs:

<div id="primary-div">

  <div class="child dairy">
    <div class="title">Title</div>
    <div class="text">Lorem ipsum</div>
  </div>

  <div class="child dairy">
    <div class="title">Title</div>
    <div class="text">Lorem ipsum</div>
  </div>

  <div class="child meat">
    <div class="title">Title</div>
    <div class="text">Lorem ipsum</div>
  </div>

  <div class="child vegetable">
    <div class="title">Title</div>
    <div class="text">Lorem ipsum</div>
  </div>

</div>

Like I said, I’m still looking, but I’m being horribly unsuccessful…

  • 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-13T05:36:09+00:00Added an answer on May 13, 2026 at 5:36 am

    Try this: (Untested)

    <a href="#" class="dairy">Dairy</a>
    <a href="#" class="meat">Meat</a>
    <a href="#" class="vegetable">Vegetable</a>
    $('a').click(function(e){
        var myId = $(this).attr('class');
    
        $('#primary-div div.child:not(.' + myId + ')').hide();
        $('#primary-div div.child.' + myId).show();
    
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a javascript assignment and have just learned that I can do it
I have a table that is quite modest in size at the moment but
Would having a nice little feature that makes it quicker to write code like
I hope somebody can help me here, I have a table that has the
I've got a SQL query that joins a pricing table to a table containing
I've got a query that I've just found in the database that is failing
It appears that my automatic CakePHP table columns - created and modified - are
I'm converting an Access application to web, and need to print reports from it.
I have some dirty input data that is being imported into a raw source
Why would the following query return Error converting data type varchar to bigint? Doesn't

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.