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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:37:32+00:00 2026-05-12T18:37:32+00:00

I have a (semantically incorrect) HTML like this: <ul> <li class=year>2009</li> <li><a href=project1.html>Project 1</a></li>

  • 0

I have a (semantically incorrect) HTML like this:

<ul>
<li class="year">2009</li>
<li><a href="project1.html">Project 1</a></li>
<li><a href="project2.html">Project 2</a></li>
<li><a href="project3.html">Project 3</a></li>
</ul>

<ul>
<li class="year">2008</li>
<li><a href="project4.html">Project 4</a></li>
<li><a href="project5.html">Project 5</a></li>
<li><a href="project6.html">Project 6</a></li>
</ul>

<ul>
<li class="year">2007</li>
<li><a href="project7.html">Project 7</a></li>
<li><a href="project8.html">Project 8</a></li>
<li><a href="project9.html">Project 9</a></li>
</ul>

and a jQuery script like this:

$(function() {
    $('.year').click(function() {
        $('ul').find('li:not(.year)').slideUp('fast');
        $(this).closest('ul').find('li:not(.year)').toggle('fast');
    })
})

It works almost as needed. By default all ul li-s are hidden except those having the class year. When the user clicks on a year, any opened year’s links slide up and the clicked year’s links slide down. The problem is that if I click on a year when it’s opened it first slides up (being intercepted by the first line) and then slides down via the toggle line. I’d like it to stay closed with the slide up line not intercepting the currently clicked year.

Hope this makes sense.

Any help appreciated.

  • 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-12T18:37:32+00:00Added an answer on May 12, 2026 at 6:37 pm

    May be you should use the :hidden or :visible selector to distinguish which are already shown.

    $(function() {
        $('.year').click(function() {
            $('ul').find('li:not(.year)').slideUp('fast');
            $(this).closest('ul').find('li:not(.year):hidden').toggle('fast');
        })
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML document where I would like to semantically group text to
Let's say we have class X with defined constructor X(int value) . Is this
I have a very simple mapping like: public abstract class EntityMap<TEnt, TId, TDto> :
I have a chunk of a page that looks semantically this: Heading A Textual
Let's say I have an SQL statement that's syntactically and semantically correct so it
Have you managed to get Aptana Studio debugging to work? I tried following this,
This is a question I have been struggling with for a while. What is
Here's my dilemma: I have two types of routes which are semantically very different,
I'd like to have the compiler warn me if I'm not handling every if
I'd like to have a logo (say it's square for simplicity) with 4 links

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.