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

  • Home
  • SEARCH
  • 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 6567831
In Process

The Archive Base Latest Questions

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

I have several divs on a page all with the class article. I used

  • 0

I have several divs on a page all with the class “article.” I used

$(".article:first").addClass("current");

to add the class “current” to the first div with class “article.” I want all other class=”article” divs to be hidden until a button is clicked.

When the page loads, the first class=”article” div should be visible. When a button is clicked, the 2nd div should appear, and so on.

Edit: Does it matter that the class=”article” divs appear in two differently-classed divs?

<div class="roots">
   <div class="article">
   </div>
</div>
<div class="words">
   <div class="article">
   </div>
</div>

Would I have to address them differently in JQuery?

  • 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-25T14:23:01+00:00Added an answer on May 25, 2026 at 2:23 pm

    You can set the initial state of only the first one showing with this jQuery:

    $(document).ready(function() {
        $(".article").hide();  // hide them all
        $(".article:first").show().addClass("current");  // show first one and add class
    });
    

    Though, I wouldn’t personally use JS for the initial state myself because they elements may show briefly before the JS runs and it might not look so clean. It might be better to have .article be hidden by default with CSS:

    .article {display: none;}
    

    And, then you run this initial javascript to show the first one and add your current class:

    $(document).ready(function() {
        $(".article:first").show().addClass("current");  // show first one and add class+
    });
    

    Then, upon a button press, to show the next one that’s hidden you can execute this:

    $("#showButton").click(function() {
        $(".article:hidden:first").show();
    });
    

    You can see a working example of this here: http://jsfiddle.net/jfriend00/RPPYz/.

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

Sidebar

Related Questions

I have a page with several div's. All of the divs have a unique
I have several divs with one class on a page. <div class=main/> <div class=main/>
I have several divs that I want to work with dynamically. <div class=parent-19 id=123>
I have a page with the several divs like: By default all are display:none,
I have several divs on a page. They are formatted like: <div id='profile-1'></div> <div
I have a div with several other divs inside it. I would like to
If you have several div s on a page, you can use CSS to
I have several divs that share a common class. If one of these divs
I have a container DIV which contains several block-DIVS. Every block-DIV contains SPAN items
I have a DIV container with several inner DIVs layed out by floating them

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.