Need help with a basic accordion script.
I've got my accordion working.
http://www.bassettboy.com/salt2/
The html and jq are as follows
- <div class="nav">
- <h3><div></div>
- <h3><div></div>
- <h3><div></div>etc..
- </div>
- $(document).ready(function() {
- $('div.nav> div:gt(0)').hide();
- $('div.nav:eq(0)> h3').click(function() {
- $(this).next('div:hidden').slideDown('fast')
- .siblings('div:visible').slideUp('fast');
- });
- });
This hides all divs except the first one (check the site) on load, then whenever I click a h3, it performs as an accordion, sliding the hidden div down and other visible divs back up.
I want to add another functionality. I want it to be like, if you click on a h3, and the next div is already open, it will hide that div. else, it performs this function. This would be a basic if/else then wouldn't it? I'm new to jq but I've done mIRC scripting in the past and I don't know how the selectors work yet. Any help?