Show div after 10 secs and hide after 10 secs

后端 未结 6 1426
[愿得一人]
[愿得一人] 2021-01-17 07:04

I need to show a div (e.g. #mybox) in 10secs after page load, keep it visible for another 10 secs and then hide with a nice sliding in/out effects.

Thanks a lot for

6条回答
  •  遥遥无期
    2021-01-17 07:35

    Please use the below function:

    cycle();
    function cycle() {
         $('#myid')
        .delay(10000)
        .fadeIn(300)
        .delay(10000)
        .fadeOut(300, cycle);
    }
    

    If we don't need a loop, then just one line of code is needed:

    $('#myid').delay(10000).fadeIn(300).delay(10000).fadeOut(300);
    

提交回复
热议问题