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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:32:28+00:00 2026-06-07T22:32:28+00:00

I have this markup <div id=content > <h1><a href=#>Sample 1</a></h1> <img src= alt=sample 1

  • 0

I have this markup

<div id="content" >
      <h1><a href="#">Sample 1</a></h1>
      <img src="" alt="sample 1" />

       <h1><a href="#">Sample 2</a></h1>
      <img src="" alt="sample 2" />

       <h1><a href="#">Sample 3</a></h1>
      <img src="" alt="sample 3" />

       <h1><a href="#">Sample 4</a></h1>
      <img src="" alt="sample 4" />
</div>

I want that all images hide when the page loads, then when I click on every “h1”, its image slide down and when I click on it again, it slides up.
1- consider that I do not want all images slide down and up when I click on a “h1”, just the related image slides up and down.

help me please

  • 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-07T22:32:30+00:00Added an answer on June 7, 2026 at 10:32 pm

    It should be as simple as something like this:

    //On DOM ready...
    $(function () {
    
        //Hide all `img` elements...
        $("img").hide();
    
        //Bind click event handler to `#content`, responds to clicks on `h1`
        $("#content").on("click", "h1", function () {
    
            //Find the immediately following sibling and slide it up/down
            $(this).next().slideToggle();
        });
    });
    

    Note that the above takes advantage of event delegation so only one event handler exists instead of one for every h1 element, which is more efficient.

    References:

    • .on()
    • .next()
    • .slideToggle()
    • .hide()

    I recommend that you spend some time reading through the jQuery API and getting to know it. It shouldn’t have been difficult to figure out the above just by looking at the methods available to you.

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

Sidebar

Related Questions

I have this markup: <div id=slider1> <div class=ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all> <a style=left:
Suppose I have this html markup: <div id=wrapper> <pre class=highlight> $(function(){ // hide all
I have following HTML markup, <div id=subcontent_l> <p> <a href=/membership-packages/><img height=202 width=644 alt= src=http://74.52.72.231/wp-content/uploads/2010/06/banner1.jpg
I have this markup: <div class=news-listItem> <p class=date>Date: 06.03.2012</p> <h2><a href=#>test aaaaa</a></h2> <div class=news-content>Lorem
I have my markup like this (for argument's sake) <div id=content></div> <div id=layout></div> <div
I have this markup <div class=input text> <label for=Experience0ExperienceContent>Experience Content</label> <input name=data[Experience][0][experience_content] class=span3 id=Experience0ExperienceContent
I have, for example, markup like this <div id=content> <p>Here is some wonderful text,
I have a markup like this: <div class=classA classB>the content</div> What I would like
I have this markup: <div class=myToggledDiv> <div>content</div> </div> <div style=margin-top: 10px;> content </div> Via
Let's say I have a this markup: <div id=container> <div id=header>content</div> <div id=left-column>content</div> <div

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.