gpt4 book ai didi

javascript - jquery 表单提交 - 显示 div 并提交

转载 作者:行者123 更新时间:2023-11-27 23:34:57 25 4
gpt4 key购买 nike

我正在尝试制作 jQuery 脚本,点击表单提交后将使 div 显示: block 并在 5 秒后提交我的表单。

下面 header 代码中的代码 - 即使用于测试提交延迟也不起作用:

<script>
$('#registerform').submit(function (e) {
var form = this;
e.preventDefault();
setTimeout(function () {
form.submit();
}, 1000); // in milliseconds
});
</script>

点击提交后这个div应该变成可见的形式:

<div id="gif"><img src="img/digital_signature.gif" /></div>

5 秒后该表单应提交:

<form action="todo.php" method="post" id="registerform">
<div class="input-holder">
<input class="fname" type="text" name="login" placeholder="Firstname">
</div>
<div class="input-holder">
<input class="fname" type="text" name="pass" placeholder="Lastname">
</div>
<div class="input-holder">
<input class="city" type="text" name="pass" placeholder="Postal Adress">
</div>
<div class="input-holder">
<input class="city" type="text" name="pass" placeholder="City">
</div>
<div class="input-holder">
<input class="city" type="text" name="pass" placeholder="Country">
</div>
<div class="input-holder">
<input class="email" type="text" name="pass" placeholder="E-mail">
</div>
<div class="input-holder">
<input class="revenue" type="text" name="pass" placeholder="Your Value">
</div>
<div class="input-holder">
<textarea rows="1" class="baddress" placeholder="Secret address"></textarea>
</div>
<div class="input-holder">

<input type="file" class="custom-file-input" name="SCAN" id="fileToUpload" />
</div>

<input type="submit" value="Login" id="submit">

</form>

最佳答案

http://codepen.io/anon/pen/gPayYe

 $('#submit').on('click', function (e) {
alert('button clicked: submitting in 5 seconds')
$('#gif').show();
e.preventDefault();
setTimeout(function () {
$('#registerform').trigger('submit');
}, 5000); // in milliseconds
});
$('#registerform').on('submit', function() {
alert('form submitted')
});

关于javascript - jquery 表单提交 - 显示 div 并提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34270044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com