Home >Web Front-end >JS Tutorial >jQuery implements a method to automatically submit a form after a few seconds_jquery

jQuery implements a method to automatically submit a form after a few seconds_jquery

WBOY
WBOYOriginal
2016-05-16 16:11:001330browse

The example in this article describes how jqury can automatically submit a form after a few seconds. Share it with everyone for your reference. The details are as follows:

Many download websites have set up this code. The download button will count for a few seconds. After counting, you can click Submit
It’s easy to make:

1. The js part code is as follows:

<script language='javascript'>
<!--
$(document).ready(function(){
  // #formDownload ajaxForm
  $('#formDownload').ajaxForm({
    target:'#formDownloadWindows',success:function(){
    }
  });
});
function jump(count,formId) {
  window.setTimeout(function(){
  count--;
  if(count > 0) {
    $('#jumpNum').html(count);
    jump(count,str);
  } else {
    $(str).submit();
  }
  }, 1000);
}  
//-->
</script>

2. The HTML part of the code is as follows:

<form action="/action/download" method="post" id="formDownload">
Wait <span id="jumpNum"></span> seconds
<input type="button" onclick="jump(30,"#formDownload");" />
</form>

I hope this article will be helpful to everyone’s jQuery programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn