i'm having problems with this code:

        if ($('.carousel ol').children('li.panel').length > 0) {
                $('.carousel ').append('<ul class="nav-carousel"></ul>');       
                
                        // build links  
                        $('.carousel ol').each(function(i){                     
                                
                                var carouselNavDivs = $('ul.nav-carousel');     
                        
                                $(carouselNavDivs[i]).append('<li> # previous 
</li>');  
                                        $(this).children().each(function(j){
                                                linkNum = j+1;
                                                
$(carouselNavDivs[i]).append('<li class="indicator"> # '+linkNum+'
</li>');                        
                                        });
                                $(carouselNavDivs[i]).append('<li> # next 
</li>');      
                        });
}
                

it executes correctly, but it puts a ul.nav-carousel on each .carousel ol.
I'm looking to only append ul.nav-carousel if there is more than one li in
the .carousel ol. each li has class .panel. 

how do i make this if statement work? i had this code before but it was
causing execution problems however it correctly appended ul.nav-carousel to
ol's with more than one child only:

        if ($('li.panel:not(:only-child)')) {
                var $this = $('li.panel:not(:only-child)').parent().parent();
                ($this).append('<ul class="nav-carousel"></ul>');               
        
                        // build links  
                        $('.carousel ol').each(function(i){                     
                                
                                var carouselNavDivs = $('ul.nav-carousel');     
                        
                                $(carouselNavDivs[i]).append('<li> # previous 
</li>');  
                                        $(this).children().each(function(j){
                                                var linkNum = 0; 
                                                linkNum = j+1;
                                                
$(carouselNavDivs[i]).append('<li class="indicator"> # '+linkNum+'
</li>');                        
                                        });
                                $(carouselNavDivs[i]).append('<li> # next 
</li>');      
                        });
        }


thanks for the help.
-- 
View this message in context: 
http://www.nabble.com/calculating-size-%28a-problem-is-if-statement%29-tp20375973s27240p20375973.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to