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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:48:18+00:00 2026-05-27T15:48:18+00:00

Hello I am doing a simple toggle that hides and shows certain blocks of

  • 0

Hello I am doing a simple toggle that hides and shows certain blocks of Text when i click on a navigation option. I am doing this by running a for loop and using length.div to determine the exact div that i want to show or hide. The seowaukebar is adding divs to my source code for example so if someone has it – the div.length changes, I needto find a cure for that. Here is my Javascript:

function forLoopToggle(id) {

var chosenTab = document.getElementById(id);

//loop between the 6th and after divs - the initial value is for Google chrome, and if someone has SEO quake because an extra div is added in that case
for (var toggle = 6;  toggle < div.length; toggle++) {

        //for clicking on experience
        if (div[toggle] == chosenTab && chosenTab.id == 'experience' && chosenTab.style.display != 'block') {   
                        div[toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[5].style.display = 'block';//employment div
                        div[6].style.display = 'none';
                    }

        //for clicking on projects
        if (div[toggle] == chosenTab && chosenTab.id == 'projects' && chosenTab.style.display != 'block') { 
                        div[toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[++toggle].style.display = 'block';
                        div[5].style.display = 'none';
                        div[6].style.display = 'block';//keyword div
                    }

        //for clicking on a div which display is currently none
        else if (div[toggle] == chosenTab && chosenTab.style.display != 'block') {
                        div[toggle].style.display = 'block';
                        div[5].style.display = 'none';
                        div[6].style.display = 'none';
        }

        //all divs that have not been clicked on will not be shown
        else if  (div[toggle] != chosenTab) {
                        div[toggle].style.display = 'none';
        }       
        else if  (div[toggle] = chosenTab && chosenTab.style.display == 'block') {
                        div[toggle].style.display = 'none';
        }   
        //allows you toggle on and off of the same div

        else {
                        div[toggle].style.display = 'none';
                        div[5].style.display = 'none';
                        div[6].style.display = 'none';
            }
}

}

  • 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-27T15:48:19+00:00Added an answer on May 27, 2026 at 3:48 pm

    You could show/hide sections like this, or toggle between two different versions of content with something like this. It does the job, although launching a javascript function from within <a href="jsFunction()"> is technically frowned upon. I need to learn how to do this properly using straight javascript, but this is a start.

    Note: In jsfiddle, I had to use inline javascript for some reason, but in practice you can put the function in separate JS file.

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

Sidebar

Related Questions

Currently I am doing this: I have text that looks like: Hello ${user.name}, this
Hello I am doing some simple inserting into a table from my <php> and
Hello i'm trying to make a simple ios app with tabs and navigation .
Ok this is a continuation from this question: How to make a simple Hello
I am doing a hello world on threads, i have created a simple thread
I'm not sure if there is a simple way of doing this, but is
I'm doing my first steps with JNI and tried to write a simple Hello
I have a simple hello world python script: #!/usr/bin/python print Content-Type: text/html print print
I'm new to Java and IntelliJ and I am just doing a simple hello
What am I doing wrong here: class Helo { // main: generate some simple

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.