html - jQuery click on button will show the div and again click on any area of the page will hide the div? -


i have markup this. button click.

<div class="logout-wrap">   <div class="account-info"> <a href="../profile.php">admin admin</a> </div><!--.account-info--> <div class="account-info-icon">   <ul>     <li><a href="" class="account-sprited notice"><span>5</span></a></li>     <li><a href="" class="account-sprited profile profiletest"></a></li>   </ul> </div> </div> 

it area default hide , when click on button show div contents.

<div class="account-info-box" style="display: block;">   <div class="top-info">     <div class="profile-img">       <img alt="" src="../images/profile.png">     </div><!--.profile-img-->     <div class="profile-text">       <span class="username">sgsh dshjds</span>       <span class="acctype">account type- agent</span>       <span class="view-profile"><a href="" class="profile">view profile</a></span>     </div><!--.profile-text-->   </div><!--.top-info-->   <div class="bottom-info">     <ul>       <li><a href="" class="profile">create account</a></li>       <li><a href="" class="profile">signout</a></li>     </ul>   </div><!--.bottom-info--> </div> 

here when page loads div account-info-box hide. when click on profile show div account-info-box. have jquery this

<script type="text/javascript">   jquery(document).ready(function() {     jquery('div.account-info-box').hide();       jquery('a.profile').click(function(event){         event.preventdefault();         jquery('div.account-info-box').show();     });   }); </script> 

but here want when again click on other area of page again hide. can kindly tell me how this. , suggestions appreciable. thanks

edit have changed jquery code this

jquery(document).ready(function() {     jquery('div.account-info-box').hide();     jquery('.profiletest').click(function(event){       event.preventdefault();       jquery('div.account-info-box').show();    });  });   jquery(document).ready(function(event) {   if(event.target.classname !== 'profiletest') {     jquery('div.account-info-box').hide();   }  }); 

now showing error typeerror: event.target undefined

<script type="text/jscript"> document.click = hide();  //to show on button click $(".bottom-info").click(function(){ $(".account-info-box").attr("display","block"); });  //to hide hide(function(){ $(".account-info-box").attr("display","none"); });  <script> 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -