我创建一个表单并将请求发送到其他页面:
$(document).ready(function() {
$("#send").click(function() {
var text = $("#text").val();
var email = $("#email").val();
$("#exp").load("sendmail.php",{text:text,email:email});
});
});
和我的表单代码:
<ul>
<li><input type="text" name="name" id="text" /></li>
<li><input type="text" name="email" id="email"/></li>
<button class="button" id="send" >send email</button>
<div id="exp" style="color:green;"></div>
</ul>
如何在发送邮件后隐藏提交按钮?
最佳答案
jQuery:
$(document).ready(function() {
$("#send").click(function() {
var text = $("#text").val();
var email = $("#email").val();
$.post("sendmail.php",{text:text,email:email}, function(){
$('.form').hide();
});
});
});
HTML:
<ul class="form">
<li><input type="text" name="name" id="text" /></li>
<li><input type="text" name="email" id="email"/></li>
<button class="button" id="send" >send email</button>
<div id="exp" style="color:green;"></div>
</ul>
关于javascript - 使用 load 方法发送表单后隐藏提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26300917/