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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:46:26+00:00 2026-05-23T14:46:26+00:00

does anyone know of a simple script to have a list of items and

  • 0

does anyone know of a simple script to have a list of items and show/hide one <li> at a time without engaging ALL of them in the list? Just seeing if anyone had something clever.

enter image description here

I want to find the parent of each link in a list so it only slideToggle’s the appropriate <li> as you go down. I’m trying to list classes for a school and you can open them and see more as you go along, but not open ALL of them at once, and without writing 200 click statements 😉

$('.link').click(function() {
  $('.li').slideToggle();
});


$(this).parent().parent().next('.toggle').toggle('slow')
or

$(this).closest('tr').next('.toggle').toggle('slow');
  • 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-23T14:46:26+00:00Added an answer on May 23, 2026 at 2:46 pm

    Why not using this:

    $('.link').click(function(){
        $(this).parents('.li').slideToggle();
    });
    

    To explain, in an event handler you have access to the element that triggered the event via this.

    From there, all you need to do is place that element via this in a jQuery object $(this), and use jQuery’s traversal methods to locate the element you’re targeting.

    Also, please note that '.li' will look for an element that has the class named li applied to it.

    If you were actually targeting the <li> elements irrespective of their class, then you’d want to remove the ..

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

Sidebar

Related Questions

Possible Duplicate: PHP: Script for generating Crossword game? Does anyone know any PHP-based simple
Does anyone know of a simple HTML5/CSS3 framework which applies a minimum of formatting
Does anyone know of a simple way to set a selected index or item
Does anyone know of some (very) simple tutorials on line on the WCF? Basically
Does anyone know of any tools to provide simple, fast queries of flat files
Does anyone know where I may find a really simple easy jQuery and PHP
Does anyone know of a way to simply and effectively brighten a UIImage by
Does anyone know if there is an sample code for using Visual Basic to
Does anyone know a better (shorter/more elegant) way than simply writing a loop and
Does anyone know if there is a way to generate different code in the

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.