Reputation: 1331
I am using a onclick function on my form submit button to hide a 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.
<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>
Upvotes: 0
Views: 8355
Reputation: 150253
$('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;
});
Upvotes: 9