您可以使用action="javascript:void(0)"
然后使用Ajax处理表单数据提交,而不是重定向到感谢页面。
例如:
$("form").submit(
function(){
//Send data with Ajax to the backend using $.ajax() function and then on the callBack function do something with your html e.g.
$("form").fadeOut(function() {
$(".response").fadeIn();
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
<form action="javascript:void(0)">
<input type="text" name="userName">
<input type="text" name="password">
<input type="submit">
</form>
<div class="response" style="display:none">
Thank you!!
</div>
</div>