I have tried other helpful comments but still can not get my code to work. I am new to js so I really appreciate any help I can get. Thanks you.
// Form submit
$(".feedback-form").submit(function(e){
$('.message', this).remove();
if($(".feedback-form").valid()){
e.preventDefault();
$(this).prepend('<div class="loading"></div>');
dataString = $(".feedback-form").serialize();
$.ajax({
type: "POST",
url: "send.php",
data: dataString,
success: function(data) {
$('.feedback-form .loading').remove();
$('.feedback-form').prepend('<div class="message message-ok">Sent successfully!</div>').find('.message').fadeIn().delay(5000).fadeOut();
$('feedback-form')[0].reset();
您可以在成功功能中尝试以下方法:
$(".feedback-form").find("input[type=text], textarea").val("");
I think you forgot "." in selector
$('feedback-form')[0].reset();
Correct it to:
$('.feedback-form')[0].reset();
So, check if this can help you.
Else, other options using jquery and javascript:
$('.feedback-form').trigger("reset");
$(".feedback-form").get(0).reset();
document.getElementsByClassName('feedback-form').reset();
And using input type reset
:
<input type="reset">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.