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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:45:06+00:00 2026-05-30T19:45:06+00:00

I am sorry about how simple this question might be, but I cannot find

  • 0

I am sorry about how simple this question might be, but I cannot find the information I am looking for. I have two divs on my page and they are controlled by some jQuery that will open and close them. When the page loads they are both defaulted to close. I was wondering how I would make one default to open (loginDiv) when the page loads or does a post back? I am very novice at jQuery and the person that helped me this far is not an option right now. Thanks in advance!

Here is the code:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript">
    // <![CDATA[

    (function($) {
        var containers = ['login', 'account'];

        var toggle = function(container, flag) {
            span = $('#' + container + 'Link').find('span');
            div = $('#' + container + 'Div');

            div[flag ? 'slideDown' : 'slideUp']();
            span.html(flag ? '-' : '+');
        };

        var clickHandler = function() {
            container = this.id.match(/^[a-z]*/);
            flag = $(this).find('span').html() == '+';
            toggle(container, flag);

            if (flag) {
                for (i = 0, j = containers.length; i < j; i++) {
                    con = containers[i];


                    if (con != container)
                        toggle(con, 0);
                }
            }
        };

        $(function() { // on load

            for (i = 0, j = containers.length; i < j; i++)
                $('#' + containers[i] + 'Link').click(clickHandler);

        });

    })(jQuery);

    //]]>
</script>

//And here are the divs:
<div id="loginDiv" style="display:none">...</div>
<div id="accountDiv" style="display: none;">...</div>

I tried changing the display on the loginDiv to anything but none, and it still does not work properly.

  • 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-30T19:45:07+00:00Added an answer on May 30, 2026 at 7:45 pm

    You can do something like this:

    http://jsfiddle.net/ufomammut66/Em64X/

    Basically the page intializes with the elements not displayed. When the page loads (thats the $function(){ bit) we set the login elements css value 'display' as block. and bam – we have a visible element on page load.

    I also included a quick little toggle button there for displaying only one at a time. I’m not 100% sure what you’re trying to do there but it looks like you’re trying to find all one one element – add a click event to it to do stuff. This one just does a slide toggle on anything with the class ‘hideAble’ which both or divs there do have.

    Hope this helps.

    EDIT: Added changing of span’s text on load.

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

Sidebar

Related Questions

This is not the clearest of question titles, sorry about that, but I will
Hello I am sorry to bother you with such a simple question but this
This may be very simple question, sorry about my lack of knwoledge, and my
Hello yeah I'm asking this question a second time, sorry about that but I
Sorry for really simple question, but I wasnt able to find anything in the
Sorry to put a post up about something so simple, but I don't see
Sorry about the extremely vague question title (any suggestions for improvements welcome) I have
Sorry about the wording for my question title. I have a basic HTML anchor
I'm sorry about the naive question. I have the following: public Array Values {
Sorry about this silly question. I'm trying to learn objc and I'm unable to

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.