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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:10:33+00:00 2026-06-06T04:10:33+00:00

I want to hide all other LI’s in a certain UL except the LI

  • 0

I want to hide all other LI’s in a certain UL except the LI that I select.

<ul>
  <li><div></div></li>
  <li><div></div></li>
</ul>
<ul>
  <li><div></div></li>     -- HIDE
  <li><div></div></li>     -- SELECT
  <li><div></div></li>     -- HIDE
</ul>
<ul>
  <li><div></div></li>
  <li><div></div></li>
</ul>

How can I solve this the best way?

I’ve tried using indexes, but having some problems getting it to work, and selecting the correct UL. As you may see, I’ve got no class on the UL’s or LI’s so I think the only option is LI’s.

What I really do, is selecting a div inside the LI so, I get the selected LI’s index by:

var li_index = $(this).parent().index();
  • 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-06T04:10:35+00:00Added an answer on June 6, 2026 at 4:10 am

    You traverse the DOM up from the div that was clicked then hide the other elements with .not($(this).parent()).toggle() -> Not the li that surrounds this div

    $('div').click(function () {
        $(this).closest('ul').find('li').not($(this).parent()).toggle();
    });
    

    .toggle() can be replaced with .hide() if you don’t want the User to be able to reverse their decision.

    JS Fiddle: http://jsfiddle.net/tDmy3/2/

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

Sidebar

Related Questions

I want to hide all div's hide when clicked on the body of the
I want to hide all mysql error messages without using mysql_error() . Are there
I want to hide all the descendents of the ul for my tree menu
i have the following html , and i want to hide all lsHeader which
all I want to show hide some ids using jQuery. My html code is
I want hide some fields in existed XML and use that XML as Input
I want to hide the cursor when showing a webpage that is meant to
I'm using WebBrowser control to load my page. I want to hide all the
I Load this way: $('.selector').each(function(){ $(this).qtip({ content: { url: '/qtip.php?'+$(this).attr('rel')+' #'+$(this).attr('div'), text:'<center><img src="/images/loader.gif" alt="loading..."
How can I hide the column with all empty cells including the title <th>

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.