Jquery delay not working correctly

后端 未结 4 1621
南旧
南旧 2021-01-28 23:46

I want to create a delay between these two messages:

$(\'#submit-account\').html(animation + \'Submitting Data\')
$(\'#submit-account\').html(animation + \'Valid         


        
相关标签:
4条回答
  • 2021-01-29 00:19

    I'm not sure if i'm understanding it precisely or correct but there's a Default Built in JavaScript setTimeOut(); Function.

    For more info :How to wait 5 seconds with jQuery?

    0 讨论(0)
  • 2021-01-29 00:22

    I think that problem is because delay() only delays item(s) in a queue (jQuery queues automatically only animations). So try to modify fade function to fadeIn(0) and jQuery will interpret it as animation and now delay should works.

    0 讨论(0)
  • 2021-01-29 00:22

    maybe you need to link JQuery 1.9.1, this is working: jsFiddle is here

    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    

    and note that delay() method is for delaying between queued jQuery effects.

    take a look at this jsFiddle


    reference


    0 讨论(0)
  • 2021-01-29 00:27

    make sure the #submit-account is hidden already.

    instead of your code you can try this

    $('#submit-account').html(ani + "Wait").fadeIn(5000);
    
    
     $('#submit-account').html(ani + "Done").fadeIn(5000);
    

    This will control the speed of the fadein effect. or if you want the div to be fadein after some time, you can use the setTimeOut() function.

    Hope this will help you

    0 讨论(0)
提交回复
热议问题