How to fade out div slowly, update content, and then fade in div slowly, using jQuery?

前端 未结 6 1561
梦如初夏
梦如初夏 2020-12-10 02:52

I have a div I want to fade out, update its content, and then fade back in. So far I have tried:

$(\'#myDivID\').fadeOut(\'slow\', function() {
         


        
6条回答
  •  粉色の甜心
    2020-12-10 03:52

    use SetTimeOut

    setTimeout(function() { $('#myDivID').fadeIn('slow'); }, 5000);
    

    this works

    jsFiddle http://jsfiddle.net/3XYE6/1/

    $('#doit').click(function(){
        $('#myDivID').fadeOut('slow', function() {
            $('#myDivID').html('New content in MyDiv ('+Math.random()+')')
            setTimeout(function() { $('#myDivID').fadeIn('slow'); }, 5000);
        });    
    })
    

提交回复
热议问题