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

The Archive Base Latest Questions

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

I have a series of divs that I’ve hidden with css display:none;. <div id=

  • 0

I have a series of divs that I’ve hidden with css display:none;.

<div id="" class="hidden_row">some code</div>
<div id="" class="hidden_row">some code</div>
<div id="" class="hidden_row">some code</div>

I also have button with an onclick “addRow();” function that is designed to sequentially display one hidden row on each click by changing its css declaration to “display:block;”.
The javascript looks like this:

function addRow(){
    var hiddenrow = getElementsByClassName(document, "*", "hidden_row");

    for(var i=0; i< hiddenrow.length; i++){
        if(hiddenrow[i].style.display = "none"){
            hiddenrow[i].style.display = "block";
        }
    }
}

However, the function doesn’t change 1 member of the array on execution (which is what I’d like), it finds the hidden rows and displays them all. How can I tweak my function so that it works as intended?

  • 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-03T19:52:40+00:00Added an answer on June 3, 2026 at 7:52 pm

    you have a typo in your if statement

    if(hiddenrow[i].style.display = "none"){
    

    should be

    if(hiddenrow[i].style.display == "none"){
    

    EDIT:
    note that .style.display only checks the inline style, so you’ll have to check for

    if(hiddenrow[i].style.display != "block"){
    

    instead, as this better supports what you want

    and as Darhazer said, if you want to just show one at a time, you need to put a break; after you find the one you want.

    Working JsFiddle: http://jsfiddle.net/STGhq/

    and your revised function

    function addRow(){
        var hiddenrow = document.getElementsByClassName("hidden_row");
        for(var i=0; i< hiddenrow.length; i++){
            if(hiddenrow[i].style.display != "block"){
                hiddenrow[i].style.display = "block";
                break;
            }
        }
    }​
    

    Addressing the issue that element.style only pulls the current inline style, I found this article that gets around it by using window.getComputedStyle or element.currentStyle, both of which pull in the current computed style, rather that just inline declarations.

    Working jsFiddle with the new code
    http://jsfiddle.net/STGhq/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 divs: <div class=some_class active>Some Content</div> <div class=some_class>Different Content</div> <div
I have a series of <div class=clear-both></div> after a series of divs. I want
I have a series of divs like this: <div id=listofstuff> <div id=anitem> <span class=itemname>Item1</h3></span>
I have a series of divs like this: <div id=available-posts> <div class=post id=unique_id> <a
I have a series of divs of the same class; some with title attributes
I have some jQuery codes that cycles through a series of divs. I have
I have a series of divs that are hidden and I would like to
I have a series of divs that slide down using -webkit-transform from a negative
I have a series of divs that have similar ids with the exception of
I have a series of divs in two columns with some javascript dictating some

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.