[英]hiding a div after submitting a form using jquery?
I am using a onclick function on my form submit button to hide a div. 我在表单提交按钮上使用onclick函数来隐藏div。 but it is not hiding. 但它没有隐藏。 what is the best way to do this? 做这个的最好方式是什么? I want to hide a div on my page, after submitting a form. 提交表单后,我想在页面上隐藏div。
<form action="" method="POST">
<input type="submit" onclick="hide_group_posts();">
</form>
<div id='div_i_want_to_hide'>
<?php include $_SERVER['DOCUMENT_ROOT']."page.php";?>
</div>
<script>
function hide_group_posts(){
$('#div_i_want_to_hide').hide();
}
</script>
$('form').submit(function(){
$('#div_i_want_to_hide').hide();
});
If it didn't help you, one of the following must be true: 如果对您没有帮助,则必须满足以下条件之一:
Prevent it like this: 防止这种情况:
$('form').submit(function(e){
$('#div_i_want_to_hide').hide();
e.preventDefault();
// Or with: return false;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.