Div to disappear when clicking outside it

Div to disappear when clicking outside it

So, I have a content div and a floating sidebar (that's draggable). When I click on the content div, I want another div (with id #formatting) to appear inside the sidebar. This is already working.

When I click outside the content div I want the #formatting div to disappear — but if I click inside the #formatting div it also disappears. How can I get it to stay there when I click inside the sidebar?

Should I use an if statement, or are there other options?
  1. $('#content').focus(function() {
  2.   $('#formatting').show('fast', function() {
  3.     //
  4.   });
  5. });

  6. $('#content').blur(function() {
  7. $('#formatting').hide('fast', function() {
  8.     // 
  9.   });
  10. });