我喜欢在表单提交后设置5秒间隔,然后重定向到不同的页面。
以下是html代码:
<button type="button" id="submit">Submit</button>现在,我使用这个jquery重定向onclick 5秒间隔。
$('#submit').click(function(){
setTimeout(function(){
window.location.href='index.php';
},5000);
});我把.click(function()改成了.submit(function(),但没有工作。
在提交表单后,是否有办法设置5秒间隔?
谢谢。
发布于 2022-03-11 08:05:23
使用preventDefault()停止表单提交并执行代码
$('#submit').on('click', function(e){
e.preventDefault();
setTimeout(function(){
window.location.href='index.php';
},5000);
});https://stackoverflow.com/questions/71435207
复制相似问题