Home >Web Front-end >JS Tutorial >jQuery implements a method to automatically submit a form after a few seconds_jquery
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.