div not hide when submiting

div not hide when submiting

in my css i have the 
#imagefinder{
display:block;

 line-height: 1.5;
font-size: 12px ;
color: rgb(127, 124, 124);
border-top: 1px solid rgb(219, 229, 232);
}

in my demos.php

<div id="imagefinder">
Create an account or login.<br>
It only takes a minute or two - then you're ready to Go!<br></div>
<?php
                 if(!empty($err))  {
echo "<div class=\"msg\">";
 foreach ($err as $e) {
   echo "* $e <br>";
   }
 echo "</div>";
  }

?> 

What i want is when user hits the submit button and if there is errors i want the div id imagefinder to hide.

i tried a lot of stuff from google.this works for 1 sec. it hides and when the page refreshes with error its back.

<script>
$(document).ready(function(){
    $(".doLogin").click(function(){
        $(".imagefinder").hide();
   
    });
   
});
</script>
.do login is the submit button