嘿伙计们,你们中有人知道如何在我点击提交后删除文本字段吗?
我有一个“发送”按钮,单击此按钮后,应删除上面文本字段的值,并且必须再次取消选中该复选框。
我尝试了一些教程,但没有用。
这是我的代码,如果有人想帮助我
最佳答案
再试一次 jQuery:
$('#submit').click(function() {
//Other code here
//And end your function with this:
$("#name").val("");
$("#ort").val("");
$("#datum").val("");
$("input [name='Favorit']").prop("checked", false);
});
编辑:
为了让你的复选框生效,设置一个id
,例如:
<input type="checkbox" name="Favorit" id="Favorit" value="Favorit">Favorit </input>
然后用以下方法定位复选框:
$('#submit').click(function() {
//Other code here
//And end your function with this (after you gave the checkbox `id`):
$("#name").val("");
$("#ort").val("");
$("#datum").val("");
$("#Favorit").prop("checked", false);
});
关于javascript - 提交后如何清除文本字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40817673/