Close Toggle on outside click
===

I'm still quite new to javascript and JQuery...How do I get this div to close by clicking outside the toggle area (I don't want the user to have to use a close button) 

the code looks like this:

     function toggleDiv(divId) {
     $("#"+divId).toggle();
     }

     function showonlyone(thechosenone) {
     $('.newnote').each(function(index) {
          if ($(this).attr("id") == thechosenone) {
               $(this).show(0);
          }
          else {
               $(this).hide(0);
          }
     });
     }


and the html looks like this

    <div class="note">
                    
         <a id="myHeader1" href="javascript:showonlyone('newnote1');" >
              <img src="images/SN_NotesPage_14.png">
         </a>      
                
         <div class="newnote" id="newnote1">
              <a>
                   <img src="images/SN_NotesPage_16.png">
              </a>
         </div>
    </div>

thank you
