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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:39:39+00:00 2026-06-15T19:39:39+00:00

First off I’m not 100% sure how to title this page so please edit

  • 0

First off I’m not 100% sure how to title this page so please edit if you can.

So I’m Learning so jQuery, I want a system that has a number of articles on a page, when the page is first loaded i want the first article to be displayed and all other articles to be reduced to either their heading text or a set height.

Now I have a system that will open and close the containers, it looks like that:

<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery(".content").hide();

        //toggle the component with class msg_body
        jQuery(".heading").click(function() {
            jQuery(this).next(".content").slideToggle(500);
        });
    });
</script>

my Mark up is this:

<div class="page_content">
    <h1 align="center">Updates</h1>
    <article class="update_article">
        <h2 class="heading">13/12/2012 - Article Heading</h2>
        <div class="content">
            Article Body
        </div>
    </article>

    <article class="update_article">
        <h2 class="heading">13/12/2012 - Article Heading</h2>
        <div class="content">
            Article Body
        </div>
    </article>
</div>  

When this runs, all articles will be reduced to just their headings, once they have been clicked jQuery will open the body.

So I want to know how I would go about firstly opening the first article when the page is loaded, but I would also like for the system to close the open article when a different one is clicked and opened.

Thanks for you help and any tutorials or reading information for this subject is very welcome.

  • 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-15T19:39:41+00:00Added an answer on June 15, 2026 at 7:39 pm
    jQuery(".content").hide();
    //toggle the componenet with class msg_body
    jQuery(".heading").click(function() {
        jQuery(".content").slideUp();
        jQuery(this).next(".content").slideToggle(500);
    });
    
    jQuery(".heading:first").click();​
    

    Demo.

    You can slightly enhance it to not slide in/out the currently shown article, e.g.:

    jQuery(".content").hide();
    //toggle the componenet with class msg_body
    jQuery(".heading").click(function() {
        var $nextContent = jQuery(this).next(".content");
        jQuery(".content").not($nextContent).slideUp();
        jQuery(this).next(".content").slideToggle(500);
    });
    
    jQuery(".heading:first").click();​
    

    …but it depends on what your exact requirements are.

    Demo.

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

Sidebar

Related Questions

First off, I know this is a base JS issue, not jQuery. I am
First off, please forgive the stupidness of this question but Im not from a
First off, I'm not entirely sure that my question title is very descriptive, so
First off, this is part of an extra credit homework, so please do not
First off, please accept my apologies if this question is basic, I mainly have
First off, I'll say I'm not the most competent C++ programmer, but I'm learning,
First off, either A) I'm not investigating into this hard enough or B) I've
First off, I realize most of this can also be done using ItemTemplates. If
First off, this isn't exactly the ideal way of setting up a page, however
First off, an apology as I am sure this is question's answer is quite

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.