[英]Clear form field in jQuery after form submission
After submission comments, my comment form slides up and hides.提交评论后,我的评论表单会向上滑动并隐藏。 I'm using this code, which works:
我正在使用此代码,该代码有效:
$("#pm-post-form").slideUp("normal", function(){
$("#mycommentspan").html(g.html).show();
if (g.preview == true) {
$("#be_the_first").hide();
$("#preview_comment").html(g.preview_html).fadeIn(700)
}
})
But I don't want hide it anymore, so users can place others comments.但我不想再隐藏它,所以用户可以发表其他评论。
I tried this code without success:我尝试了这段代码但没有成功:
$("#pm-post-form").val("", function(){
$("#mycommentspan").html(g.html).show();
if (g.preview == true) {
$("#be_the_first").hide();
$("#preview_comment").html(g.preview_html).fadeIn(700)
}
})
I used val("")
to clear form field content after comment submission, but it doesn't work.我在提交评论后使用
val("")
清除表单字段内容,但它不起作用。
I tryed this solution that works.我尝试了这个可行的解决方案。
$("#mycommentspan").html(g.html).show();
if (g.preview == true) {
$("#be_the_first").hide();
$("#preview_comment").html(g.preview_html).fadeIn(700); // comment placed
$("#c_comment_txt").val("") // textarea where use place comment, that after submission is cleared
}
After submission, user can place new comment without refresh page.提交后,用户无需刷新页面即可发表新评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.