我有一个小主页,它通过使用JQuery脚本隐藏/显示必要的块来显示块/无属性,在同一个窗口中工作:
$(document).ready(function(){
$(".show").click(function (){
$(".web, .about, .tel, .email").hide();
$("." + $(this).attr("show-class")).fadeIn("fast");
});
});
HTML是:
<li><a href="#" class="show" show-class="email">E-mail</a></li>
<div class="email">
<form method="post" action="">
<input name="name" placeholder="Name (required)">
<input name="email" type="email" placeholder="E-mail (required)">
<textarea name="message" placeholder="Message"></textarea>
<input name="submit" type="submit" value="Submit">
</form>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = 'example@example.com';
$subject = 'Hi! From Example.com';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '') {
if (mail ($to, $subject, $body)) {
echo '<p>Your message has been sent.</p>';
} else {
echo '<p>Something went wrong, go back and try again.</p>';
}
} else {
echo '<p>Please fill in required information.</p>';
}
}
?>
</div>
问题是成功与否之后,只需在按下&#34;电子邮件&#34;后,提交表格(按提交按钮)表格隐藏。再次链接其中一条消息(例如&#34;您的消息已发送。&#34;)出现在/与表单一起。
那么如何在提交后停止表格消失呢?
谢谢!
答案 0 :(得分:1)
删除$(".web, .about, .tel, .email").hide();
这就是隐藏你输入的内容。
调整代码
$(document).ready(function() {
$(".show").click(function() {
$("." + $(this).attr("show-class")).fadeIn("fast");
});
});`