gpt4 book ai didi

jquery - 在 jquery 中提交后清除表单输入字段

转载 作者:行者123 更新时间:2023-11-28 04:19:51 25 4
gpt4 key购买 nike

我尝试使用 jquery 提交表单。表单提交正确,但提交后不清除表单。

这是我的 jquery 代码

<script type="text/javascript">
$(document).ready(function(){
$("#save").click(function(){
$("#myform").submit();
$("#myform")[0].reset();
});

});
</script>

这是我的表格

<form action="http://localhost/newsletter/index.php/email/send" method="post" accept-charset="utf-8" id="myform" name="myforms">        
<p>
<label for="name">Email Address </label>
<input type="text" name="email" id="email" value="<?php echo set_value('email');?>">

<input type="button" value="Go" id="save"></p>

</form>

我只想在提交后清除表单,但无法重置字段,数据已提交但仍保留在该字段中..有什么建议吗??

最佳答案

$("form").trigger("reset");

这肯定适用于 jQuery。

关于jquery - 在 jquery 中提交后清除表单输入字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24301668/

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