submit a form with jQuery after delay

后端 未结 2 1646
一生所求
一生所求 2020-12-18 09:37

I have a very simple form in HTML and I\'d like to submit this form after 2000ms (of delay) from when the document is ready, without push the submit button. How can I do thi

相关标签:
2条回答
  • 2020-12-18 09:52

    You need to wait with delay() function and then submit() the form itself:

    $(function() {
        $('#my_form').delay(2000).submit();
    });
    
    0 讨论(0)
  • 2020-12-18 09:57
    $(function() {
      setTimeout(function() {
       $('#my_form').submit();
      }, 2000);
    });
    
    0 讨论(0)
提交回复
热议问题