是否有“提交后” jquery选项? [英] Is there an "after submit" jquery option?
本文介绍了是否有“提交后” jquery选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个上传文件并在页面上定位iframe的表单。当用户点击提交时,我想让文件内容清除出来。
我试过了这个
<$ p $('#imagefile')。val('');
}); $('#imageaddform')。
但是它会在提交之前清除表单,所以没有上传。
如何在提交后清除?
解决方案
如果没有其他处理程序绑定,你可以这样做:
$('#imageaddform')。submit(function(e){
e.preventDefault(); //不要多次提交
this.submit(); //使用表单元素的原生提交方法
$('#imagefile')。val(' '); //空白输入
});
I have a form that uploads a file and targets an iframe on the page. When the user clicks submit, I want the file contents to "clear" out.
I tried this
$('#imageaddform').submit(function(){
$('#imagefile').val('');
});
But it clears the form before the submit, so nothing is ever uploaded.
Is how do I clear after submit?
解决方案
If you have no other handlers bound, you could do something like this:
$('#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
});
这篇关于是否有“提交后” jquery选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文