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
Release: 2016-05-16 16:11:00
Original
1341 people have browsed it

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>
Copy after login

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>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template