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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:36:29+00:00 2026-06-15T14:36:29+00:00

I have written this code. Its not working but with this you should get

  • 0

I have written this code. Its not working but with this you should get idea what i am trying to achieve

 $('.jfmfs-alpha-separator').filter(function() {
     return ($(this).next().not(".hide-filtered").hasClass("jfmfs-alpha-separator"));
  }).addClass('hide-filtered');

I have number of divs at same level. Below div with class jfmfs-alpha-separator i have number of divs and then div jfmfs-alpha-separator and again number of divs (note with below i mean at same level not child). now when all divs that follow jfmfs-alpha-separator gets class .hide-filtered I want to hide that jfmfs-alpha-separator div too.

In my code i am trying to find next div after div with class jfmfs-alpha-separator which does not have ‘hide-filtered’ class and has jfmfs-alpha-separator class. if this check retutns true i hide that div.

Example:

<div class ="jfmfs-alpha-separator">Letter A</div>
<div class ="friend hide-filtered">Aaron</div>
<div class ="friend hide-filtered">Aaron</div>
<div class ="friend hide-filtered">Ashutosh</div>
<div class ="jfmfs-alpha-separator">Letter B</div>
<div class ="friend hide-filtered">Bob</div>
<div class ="friend">Baron</div>
<div class ="friend hide-filtered">Batista</div>
<div class ="jfmfs-alpha-separator">Letter C</div> 
<div class ="friend hide-filtered">Carl</div>
<div class ="friend hide-filtered">Chris</div>
<div class ="friend hide-filtered">Charlie</div>
<div class ="jfmfs-alpha-separator">Letter D</div>
...

In above example letter A and C should get hidden because all names below it has got hide-filtered class and Letter B should remain as it is.

How do I achieve this?

Final Solution is used using Salmans Answer :

                     $(".jfmfs-alpha-separator").each(function () {
                        if ($(this).nextUntil(".jfmfs-alpha-separator").not('.hide-filtered').length == 0) {
                            $(this).addClass('hide-filtered');
                        }else{
                            $(this).removeClass('hide-filtered');
                        }
                    }); 
  • 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-15T14:36:30+00:00Added an answer on June 15, 2026 at 2:36 pm

    Here is one way to write your code:

    $(".jfmfs-alpha-separator").each(function () {
        // Assume that all elements after a .jfmfs-alpha-separator but
        // before the next .jfmfs-alpha-separator belong to same group
        var siblings = $(this).nextUntil(".jfmfs-alpha-separator");
        // Now that we have all elements that belong to the group
        // use .filter to see if all elements have .hide-filtered class
        if (siblings.filter(":not(.hide-filtered)").length == 0) {
            console.log("should hide -> ", this);
        }
    });
    

    It is easy to convert this logic to .filter(function() {})

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this login script, but for some reason its not working. I checked
In my code I have written this but it fails to compile: In Class1.h:
I have written this code inside a servlet to delete certain records from three
I have written this code in JavaScript and works perfectly fine when I include
I have written this code what it does is if user types postcode or
I have written this code outside all functions: int l, k; for (l =
I have written this code to join ArrayList elements: Can it be optimized more?
I have written this code to convert string in such format 0(532) 222 22
I have written this code in javascript however I have to make it work
I have this code written in .NET 4.0 using VS2010 Ultimate Beta 2: smtpClient.Send(mailMsg);

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.