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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:29:25+00:00 2026-05-31T17:29:25+00:00

Basically I have a series of projects displayed on the page. Each project consists

  • 0

Basically I have a series of projects displayed on the page.

Each project consists of a container div, an image div inside, then a button inside that div. With another div there which is set to ‘Display:none’. When the user clicks the ‘button inside’ the div set to ‘display:none’ slideToggles on each click…

I will have many of these on a page and am currently having to add new lines of code for the new ‘id’ of the button and the sliding div… Is there a way to detect the sliding div which is a child to the image div?

The current code I am using is:

$(function(){
    $("#lifestyledropdown").click(function(event) {
        event.preventDefault();
        $("#lifestyleimages").slideToggle();
    });

    $("#camarguedropdown").click(function(event) {
        event.preventDefault();
        $("#camargueimages").slideToggle();
    });
});

Each follow the same pattern:

Project 1:
div id = ‘name-A’dropdown (id of the button to activate the slide toggle)
div id = ‘name-A’images (id of the div that slides down)

Project 2:
div id = ‘name-B’dropdown (id of the button to activate the slide toggle)
div id = ‘name-B’images (id of the div that slides down)

Each project will have the same layout just different content so I am assuming I can use a code to detect the ‘name section’?

HTML for the projects:

<div class="projectcontent">
<div class="projectimg"><img src="images/imagemain.jpg" alt="project" />

<div id="gallerybutton">
<a href="#" id="lifestyledropdown"><img src="images/gallerycollapsewhite.png" alt="project" class="gallerycollapse"/>
<img src="images/gallerycollapseblack.png" alt="project" class="gallerycollapseB"/></a>
</div>

<div class="projecttext" style="color:#FFF;text-align:left;">
<img src="images/breakshortwhite.jpg" />

<p2>PROJECT NAME<br />
ESTOTAS AUT ALICIENI QUIBUS EXPEROR ESTIAT ESTO VOLORPORRUM EARIORIT EUM EUM ATE CUS MO ET ATEM. TAE RE VELENDI GNIATUR, UTATE ET PORUM HARIBER AERORATISI BLACCUP TATIBEA TIOREPE LLIQUAE PELENIH ILIBEA SAPITAM EUM MEUN.<p2>
</div>

<div class="expandablebox" id="lifestyleimages" style="display:none;">
<div class="projectimg"><img src="images/image-slider.jpg" alt="project" />
</div>
</div>
</div>
</div>
  • 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-31T17:29:26+00:00Added an answer on May 31, 2026 at 5:29 pm

    You can use the “ends with” $= selector to get all dropdown ids and then use next() to slideToggle() the subsequent div:

    $('div[id$="dropdown"]').click(function(ev){
        ev.preventDefault();
        $(this).next().slideToggle();
    });
    ​
    

    See demo 1

    If the images divs don’t necessarily directly follow the dropdown divs, you can use some regex to accomplish the task:

    $('div[id$="dropdown"]').click(function(ev){
        ev.preventDefault();
        $toggleDiv = $('#' + this.id.replace(/^(.*?)dropdown$/, '$1images'));
        $toggleDiv.slideToggle();
    });
    ​
    

    See demo 2

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

Sidebar

Related Questions

I have a series of databases, each of which is basically standalone. It initially
Basically I have a series of divs which contains a label and an input
Sorry if the title doesn't make sense. Basically I have a series of strings
I have a series of index files for some data files which basically take
We have a series of products with built in web servers each of which
Basically I have a series of lines in a textbox like this: ### =
I have generated a series of rows using C# and VSTO. I have basically
I have a series of boxes: <div class=box></div> <div class=box></div> <div class=box></div> <div class=box></div>
Let's say I have a series of elements designed to render via float:left inside
Ok, basically I have a view with a series of slightly overlapping subviews. When

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.