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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:05:21+00:00 2026-05-15T22:05:21+00:00

I have a series of DIVs on a page which each contain a nested

  • 0

I have a series of DIVs on a page which each contain a nested DIV which I need to be able to toggle on and off when the user clicks on a link contained in a UL. Here’s some sample code:

I need to be able to add an <li> </li> to each UL within a certain div on my page. Here is the code I have:

<div class="gallery" style="width: 67px;">
    <ul>
        <li class="info"><a href="#">Get Info</a></li> 
    </ul>
    <div class="infoPanel">  This is the panel that I need to toggle on and off</div>
</div>
<div class="gallery" style="width: 67px;">
    <ul>
        <li class="info"><a href="#">Get Info</a></li> 
    </ul>
    <div class="infoPanel">  This is the panel that I need to toggle on and off</div>
</div>
<div class="gallery" style="width: 67px;">
    <ul>
        <li class="info"><a href="#">Get Info</a></li> 
    </ul>
    <div class="infoPanel">  This is the panel that I need to toggle on and off</div>
</div>​

So, for each div.gallery I need the .infoPanel to open when the user clicks the link in li.info. I’ve been able to get one working, but can’t figure out how to constrain the jquery to each instance of the div. Any help in getting this started would be great.

  • 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-15T22:05:22+00:00Added an answer on May 15, 2026 at 10:05 pm

    I think this is what you mean.

    Try it out: http://jsfiddle.net/tjd26/

    $('div.gallery li.info a').click(function() {
        $(this).closest('.gallery').find('.infoPanel').slideToggle();
        return false;
    });​
    

    This way you are getting the .gallery ancestor for the <a> that was clicked, then from there you’re finding the .infoPanel contained inside.

    • http://api.jquery.com/closest/
    • http://api.jquery.com/find/
    • http://api.jquery.com/slideToggle/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which will have a series of tile divs, each of
I have a page with a series of divs. Each div represents a slide
I have a series of divs on a page which you can swipe left
I have a page which has DIVs which contain short phrases (one-two words) of
THE SITUATION I have a series of divs setup to contain various content: <div
I have a series of product divs in a grid, each of which is
I have a nav menu which is a series of divs, alternately a div
In short, I'm coming to have a series of divs on a page with
Basically I have a series of divs which contains a label and an input
I have a series of <div class=clear-both></div> after a series of divs. I want

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.