Отображение и скрытие div-ов в определенном временном интервале с помощью jQuery

Перебирать div каждые 10 jquery секунд.

$(function () {

    var counter = 0,
        divs = $('#div1, #div2, #div3');

    function showDiv () {
        divs.hide() // hide all divs
            .filter(function (index) { return index == counter % 3; }) // figure out correct div to show
            .show('fast'); // and show it

        counter++;
    }; // function to loop through divs and show correct div

    showDiv(); // show first div    

    setInterval(function () {
        showDiv(); // show next div
    }, 10 * 1000); // do this every 10 seconds    

});

javascript

jquery

css

html

timeout

2022-09-06T23:05:16+00:00