Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to default one panel open in jQuery
    primarykey
    data
    text
    <p>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!</p> <p>Here is the code:</p> <pre><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // &lt;![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 &lt; j; i++) { con = containers[i]; if (con != container) toggle(con, 0); } } }; $(function() { // on load for (i = 0, j = containers.length; i &lt; j; i++) $('#' + containers[i] + 'Link').click(clickHandler); }); })(jQuery); //]]&gt; &lt;/script&gt; //And here are the divs: &lt;div id="loginDiv" style="display:none"&gt;...&lt;/div&gt; &lt;div id="accountDiv" style="display: none;"&gt;...&lt;/div&gt; </code></pre> <p>I tried changing the display on the loginDiv to anything but none, and it still does not work properly. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload