JQuery auto scroll / slide show

Can I modify this existing code to automatically scroll through list items to display content?

Sorry: ul li a {} links.

Maybe the "interval" method is used?

$(document).ready(function(){
    $('ul.tabNav a').click(function() {
        var curChildIndex = $(this).parent().prevAll().length + 1;
        $(this).parent().parent().children('.current').removeClass('current');
        $(this).parent().addClass('current');
        $(this).parent().parent().prev('.tabContainer').children('.current').fadeOut('fast',function() {
            $(this).parent().children('div:nth-child('+curChildIndex+')').fadeIn('fast',function() {
                $(this).addClass('current');
            });
            $(this).removeClass('current');
        });
        return false;
    });
});
+3
source share
1 answer

There are millions of plugins that do just that. Do not reinvent the wheel and try one of these or these .

Edit: There are also special plugins for the timer, see this .

+2
source

Source: https://habr.com/ru/post/1745000/


All Articles