我尝试使用 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/