Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

396
Views
Is there an easy way to show divs by default, then filter/hide on click?

I'm looking for simple and seo/semantic way to filter and sort some content.

Initially all content should be shown, then on click the content should be filtered and only the selected group show.

I'm starting out with the code below as my base. Using widgets as example. Each widget is in its own div containing information about that widget.

Currently the default is to hide all, I'd prefer to show all to be default (I'm not sure why the very first one is showing alone on load.

Is there a way to do it without initially using display:none for the divs, my understanding is this might not be seo friendly.

$('.tab-link').click(function() {
  var contClass = $(this).data('div');
  $('.result-content').hide().filter('.' + contClass).show()
})
.result-content {
  display: none
}

.result-content:first-of-type {
  display: block
}

a {
  display: inline-block;
  margin-right: 10px;
  padding: 5px 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<a href="#" class="tab-link" data-div="widgets">All widgets</a>
<a href="#" class="tab-link" data-div="green-widgets">Green</a>
<a href="#" class="tab-link" data-div="red-widgets">Red</a>
<a href="#" class="tab-link" data-div="blue-widgets">Blue</a>

<div class="widgets green-widgets result-content">
  Widget 654
</div>

<div class="widgets green-widgets result-content">
  Widget 989
</div>

<div class="widgets green-widgets result-content">
  Widget 345
</div>

<div class="widgets red-widgets  result-content">
  Widget 563
</div>
<div class="widgets red-widgets  result-content">
  Widget 867
</div>

<div class="widgets blue-widgets result-content">
  Widget 994
</div>
<div class="widgets blue-widgets result-content">
  Widget 924
</div>
<div class="widgets blue-widgets result-content">
  Widget 114
</div>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!