Javascript 模态重置和隐藏

Javascript 模态重置和隐藏,javascript,jquery,twitter-bootstrap,twitter-bootstrap-3,Javascript,Jquery,Twitter Bootstrap,Twitter Bootstrap 3,这是我的模态布局: <div class="modal fade" id="myContact" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header">

这是我的模态布局:

<div class="modal fade" id="myContact" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
  <div class="modal-content">
    <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h3>Send me a message</h3>
    <div id="thanks"></div>
</div>
    <div class="modal-body">
    <form class="contact" name="contact">

        <input type="text" name="name" class="form-control" placeholder="Your Name"><br>

        <input type="email" name="email" class="form-control" placeholder="Your E-mail"><br>


        <textarea name="message" class="form-control" placeholder="Enter a Message"></textarea>

    </form>

</div>

<div class="modal-footer">
    <input class="btn btn-success" type="submit" value="Send!" id="submit">
    <a href="#" class="btn btn-default" data-dismiss="modal" id="close">Nah.</a>
  </div>
</div>
以及PHP process.PHP:

<?php
//add the recipient's address here
$myemail = 'test@mail.com';

//grab named inputs from html then post to #thanks
if (isset($_POST['name'])) {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
echo "<class=\"alert alert-success\" >Your message has been !";

//generate email and send!
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email\n Message \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email";
mail($to,$email_subject,$email_body,$headers);
}
?>
首先,大家好,我是新来的。。。。 我有个问题。。当我按下Send my Modal(发送模式)以隐藏但延迟以查看警报成功消息并重置时,我该怎么办

现在正在工作并发送我的电子邮件,但未关闭并重置

Thx Elod

成功后,您可以使用“重置”在模式中重置窗体

为表单使用id,如my_Contact

延迟模式隐藏可以使用setTimeout


仅供确认,您是否希望模式关闭并重置正确?对不起,我的英语是的,这正是我想要的,可能是为了隐藏延迟//回显您的消息!;//由于成功警报是模式中的回声,因此模式关闭延迟至。这一切我都试过了,但我不知道他们为什么不工作。。。我所取得的成功不是工作。。现在我意识到send messasge php没有对您发送的消息发出JSin ajax成功警报,那么如果您收到消息,请检查消息是否为空,然后隐藏并重置模型。process.php的响应中还有一件事就是在类之前添加一些标记名。现在我看到这个表单是针对Bootstrap v2.3.1的,我的页面是loding Bootstrap 3。。因为这不能正常工作。。如果我复制了BootstrapV2,我的页面就会乱七八糟,我必须用ajax激活BootstrapV3查找表单
<?php
//add the recipient's address here
$myemail = 'test@mail.com';

//grab named inputs from html then post to #thanks
if (isset($_POST['name'])) {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
echo "<class=\"alert alert-success\" >Your message has been !";

//generate email and send!
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email\n Message \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email";
mail($to,$email_subject,$email_body,$headers);
}
?>
$('#my_contact').reset(); //to reset the form
setTimeout(function() { $('#myContact').modal('hide'); }, 3000);