Fade in each li one by one

后端 未结 3 1943
春和景丽
春和景丽 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条回答
  •  离开以前
    2020-12-24 08:01

    Do something like this with animation success callback

    $(document).ready(function() {
      function fade(ele) {
        ele.fadeIn(500, function() { // set fade animation fothe emlement
          var nxt = ele.next(); // get sibling next to current eleemnt
          if (nxt.length) // if element exist
            fade(nxt); // call the function for the next element
        });
      }
      $("#circleMenuBtn").click(function() {
        fade($('#navbar li').eq(0)); // call the function with first element
      });
    });
    .sub-menu {
      left: 0;
      top: 0;
      position: relative;
      z-index: 1000;
      color: #000;
      right: 5px;
    }
    ul li {
      display: none;
    }
    
    
    

提交回复
热议问题