Having trouble with remove

Having trouble with remove

I have a new search suggestions feature that works, but I can't get it to disappear when the user clicks off.  I have tried a variety of methods to get this to work.  I just can't figure it out.

Here is the function I have come up with up to this point:

  1. <script>
  2.  var windowObj = window;
  3.  windowObj.onclick(myfunction(){
  4.   $('.results').remove();
  5.  });
  6. </script>
  7. <div id="results" class="results"></div>

I know I need code to exclude the clicks on the search results, but I just want to get this part working first.

After I start a search, and try to click off the search results, they remain.  Nothing happens.  I have googled over and over, looking at the jquery and javascript docs.  I am not sure where I am wrong.