我有一个表单,用于上传文件并以页面上的 iframe 为目标。当用户单击提交时,我希望“清除”文件内容。
我试过了
$('#imageaddform').submit(function(){
$('#imagefile').val('');
});
但它会在提交之前清除表单,因此不会上传任何内容。
提交后如何清除?
最佳答案
如果您没有绑定(bind)其他处理程序,您可以执行以下操作:
$('#imageaddform').submit(function(e) {
e.preventDefault(); // don't submit multiple times
this.submit(); // use the native submit method of the form element
$('#imagefile').val(''); // blank the input
});
关于javascript - 是否有 "after submit"jQuery 选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29020894/