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
549 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
ID: 34899941
I figured it out...changed the :first to eq(1)...works.

 
0
 

Accepted Solution

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Read about why website design really matters in today's demanding market.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 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