Solved

How do I have the second panel in a jquery accordian open as the default on page load

Posted on 2011-02-10
3
548 Views
Last Modified: 2012-05-11
I need to have item 2 open on page load instead of item 1.  How do I do that?
_______________________________________________________________________
<script type="text/javascript">
$(document).ready(function(){
      
//Set default open/close settings
$('.acc_container').hide(); //Hide/close all containers
$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
 

//On Click
$('.acc_trigger').click(function(){
      if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
            $('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
            $(this).toggleClass('active').next().slideDown(); //Add .acc_trigger class to clicked trigger and slide down the immediate next container
      }
      
      else if( $(this).next().is(':visible') ) { //If immediate next container is closed...
            $('.acc_trigger').removeClass('active').next().slideUp(); //Remove all .acc_trigger classes and slide up the immediate next container
             
      }

      
      return false; //Prevent the browser jump to the link anchor
});

 

});
</script>

----This is the page code---

<div id="accordian">
<div class="container">
<p class="acc_trigger"><a href="#1">1)&nbsp;&nbsp; &nbsp;Item 1</a></p>
<div class="acc_container">
<div class="block">
blah blah item 1


</div>
</div>
</div>
<div class="container">
<p class="acc_trigger"><a href="#2">
2)&nbsp;&nbsp; &nbsp;Item 2</a></p>
<div class="acc_container">
<div class="block">
blah blah item2

</div>
</div>
</div>
<div class="container">
<p class="acc_trigger"><a href="#3">
3)&nbsp;&nbsp; &nbsp;Item 3</a> </p>
<div class="acc_container">
<div class="block">
blah blah item 3
</div>
</div>
</div>

----------------------------------
Live code at http://www.therptsite.com/becomeapractitioner.asp
0
Comment
Question by:vmoore99
3 Comments
 

Author Comment

by:vmoore99
Comment Utility
I figured it out...changed the :first to eq(1)...works.

 
0
 

Accepted Solution

by:
ee_auto earned 0 total points
Comment Utility
Question PAQ'd and stored in the solution database.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now