淡出php echo消息

时间:2016-06-24 07:36:12

标签: php jquery

我想淡出php echo消息。这是我的PHP代码:

while

成功提交表单数据后,我得到的响应为<?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $subject = $_POST['subject']; $to = 'ajay.k@enexl.com'; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { // this line checks that we have a valid email address $mailSubject = "Contact request from " .$name; $txt = "name : ".$name.".\n\nSubject : ".$subject.".\n\nMail id : ".$email."\n\nMessage : ".$message; $headers = "From: ".$email ; mail($to,$mailSubject,$txt,$headers); $data = array(); $data['status'] = 'success'; //echo json_encode($data); echo "<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>"; echo "<p id='#text'>Your email was sent! One of our team members would contact you shortly!</p>"; // success message echo "<script type='text/javascript'>"; echo "$(function(){"; echo "$('#text').fadeOut(5000);"; echo "});"; echo "</script>"; } else{ echo "Mail was not sent, make sure that all fields are filled in"; } ?> 。但它并没有像预期的那样淡出。我怎么能让它淡出?

1 个答案:

答案 0 :(得分:4)

不要在你的id限定符中使用##text说要查找标识为text而不是#text

的元素
echo "<p id='#text'>Your email was sent! One of our team members would contact you shortly!</p>"; // success message

应该是

echo "<p id='text'>Your email was sent! One of our team members would contact you shortly!</p>"; // success message