Fade in each li one by one

后端 未结 3 1944
春和景丽
春和景丽 2020-12-24 07:14

I want to fade each nav li one by one. Here\'s my current code. It shows the whole div, now I want to fade in each li one by one with a slight dela

3条回答
  •  旧时难觅i
    2020-12-24 07:52

    You can use an each() call to loop through the li elements and delay() the fadeIn() animation by an incremental amount. Try this:

    $("#dropDownMenu li").each(function(i) {
        $(this).delay(100 * i).fadeIn(500);
    });
    .sub-menu {
        position: absolute;
        z-index: 1000;
        /* color: #fff;
        right: 5px; */
    }
    
    .sub-menu li {
        display: none;
    }
    
    

    If you want to increase/decrease the interval between items fading, change the value provided to the delay() method. In this example I used 100ms.

提交回复
热议问题