- $(document).ready(function(){
- $('ul.tabNav a').click(function() {
- var curChildIndex = $(this).parent().prevAll().length + 1;
- $(this).parent().parent().children('.current').attr('id', 'idle');
- $(this).parent().parent().children('.current').removeClass('current');
- $(this).parent().addClass('current');
- $(this).parent().attr('id', 'current');
- $(this).parent().parent().next('.tabContainer').children('.current').slideUp('fast',function() {
- $(this).removeClass('current');
- $(this).parent().children('div:nth-child('+curChildIndex+')').slideDown('normal',function() {
- $(this).addClass('current');
- });
- });
- return false;
- });
- });
I have 16 divs in the container and 4 menu buttons - I'd like to reveal 4 subsequent sibling divs at a time.
I've tried this:
- $(this).parent().children('div:nth-child('+curChildIndex+')').nextUntil('section','div').slideDown('normal',function() {
- $(this).addClass('current');
...with empty <section></section> elements as dividers, but it isn't working because it is apparently always counting from the start and not the curChildIndex var as I expected. (I obviously did not write the function.)
Suggestions on how to make it work?