Q:

jQuery button .show() click anything .hide()

I have a div, and when you click on it, used toggle() and shows and hides a list div underneath the button. I want it so that when you click anywhere on the page (not in that div*) it closes. I realize that this shouldn't work with toggle. Can someone please point me in the right direction.
I want to click a button then rather than having to click the button again to close the div I want to be able to click anywhere and it closes.

A:

You can stop the click event from bubbling, like this:
$("#divID, #buttonID").click(function(e) {
  e.stopPropagation();
});
$(document).click(function() {
  $("#divID").hide();
});

Using event.stopPropagation() a click from the "button" (which seems to be another <div>?) or from the div won't bubble up to document, anywhere else will...and when the click gets there, it'll close the <div>.  So a click from outside the <div> closes, a click from inside does nothing.

