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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:27:19+00:00 2026-06-15T14:27:19+00:00

I have a list with an arbitrary number of items. Each item has a

  • 0

I have a list with an arbitrary number of items. Each item has a number of actions that can be done onto it. I want to display those actions in a div that appears when the user clicks a link associated with the specific list item.

I have tried the following code but when I click the link it just shows the first hidden div and not the hidden div associated with the link.

<script language="javascript"> 
function toggleOptions() {
        var ele = this;
        var text = this.parentNode.getElementsByClassName("displayOptions");


    if(ele.style.display == "block") {
        ele.style.display = "none";
    text.innerHTML = "TESTING";
    }
    else {
    ele.style.display = "block";
    text.innerHTML = "Hide GPS";
    }
} 

HERE IS THE HTML. The list could be endless though, this is just an excerpt of the list.

     <a href="javascript:toggleOptions();">
        ITEM 1 OPTIONS
     </a>
      <div class="toggleOptions" style="display: none">
        ITEM 1 OPTIONS
     </div>

     <a href="javascript:toggleOptions();">
        ITEM 2 OPTIONS
     </a>
     <div class="toggleOptions" style="display: none">
        ITEM 2 OPTIONS
     </div>

     <a href="javascript:toggleOptions();">
        ITEM 3 OPTIONS
     </a>
      <div class="toggleOptions" style="display: none">
        ITEM 2 OPTIONS
     </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-06-15T14:27:20+00:00Added an answer on June 15, 2026 at 2:27 pm

    put another div or something around each group: … put the toggleOptions() function to onclick and pass the href a # so that it is not empty… pass toggleOptions(this) to know which element is clicked

    <div>
        <a href="#" onclick="toggleOptions(this);" style="display:block;">
            SHOW
         </a>
          <div class="toggleOptions" style="display: none">
            ITEM 1 OPTIONS
         </div>
    </div>
    <div>
        <a href="#" onclick="toggleOptions(this);" style="display:block;">
            SHOW
         </a>
          <div class="toggleOptions" style="display: none">
            ITEM 2 OPTIONS
         </div>
    </div>
    <div>
        <a href="#" onclick="toggleOptions(this);" style="display:block;">
            SHOW
         </a>
          <div class="toggleOptions" style="display: none">
            ITEM 3 OPTIONS
         </div>
    </div>​
    

    try with this here http://jsfiddle.net/YE6XZ/1/

    function toggleOptions(e) {
        var ele = e;
        var text = e.parentElement.querySelector('.toggleOptions')
    
    if(text.style.display == "none") {
        //ele.style.display = "none";
        text.style.display = "block";
        text.innerHTML = "TESTING";
        ele.innerHTML = "hide";
    }
    else {
        text.style.display = "none";
        //text.innerHTML = "Hide GPS";
        ele.innerHTML = "show";
    }
    
    return false;
    

    }

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

Sidebar

Related Questions

If I have a list that varies in length each time and I want
i have list of rows that user select and i want to delete them,
Let's say I have a list, with an arbitrary number of indentation levels, like
Say I have an arbitrary number of collections, each containing objects of the same
I have a list of an arbitrary number of lists, for instance: [[1,2,3], [3,4,5],
Each node of the tree might have an arbitrary number of children. I need
If I have a list of items, say apples pairs pomegranites and I want
I have a ConcurrentQueue that is being populated with an arbitrary number of objects,
Let's say I have a list of arbitrary length, L: L = list(range(1000)) What
I have a list of some arbitrary objects, for the purpose of the example

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.