I wanted to work on a form which, when clicking on a button, let the parent-form disappear. I tried several things with Javascript and after I while I got a working function that works with a click on an a-tag, but not when trying the same with the button. I don't understand why, but assume it has something to do with the button-element.
Then I have the whole form and div which contains the form (shortened, just to show the structure, the form / construction works). The following is my function:
function hideFunction() {
$("#submit").closest("#fullbody").css({"display":"none"});}<div id="fullbody" style="display:block" class="w3-content w3-white r_siu r_centered_div">
 <div id="register" role="form" class="r_form_elements">
    <form  method="post" class="form" action="profile_corp.php" enctype="multipart/form-data" autocomplete="off" >
   
   <div class="w3-row">
    <button type="submit" id="submit" name="login" class="w3-button w3-black w3-half w3-hover-yellow" onclick="hideFunction();">Add</button>
    <button class="w3-button w3-black w3-half w3-hover-pale-yellow" id="forgot">Forgot Password</button>
    <a id="submit" onclick="hideFunction();">CLICK</a>
   </div>
  </form>
 </div>
</div>So as I said, the function works when clicking on the a-tag, but not when clicking on the button. Does anybody have an idea?
Thanks in advance.
 
     
    