Focus and blur

Focus and blur

Hi there,

Here's what I'm trying to do: When I click inside a text field, a div with id #formatting appears. The #formatting div contains... well, formatting options (like bold, italic, etc.) placed in <button> elements. When I click outside the text field the #formatting div has to disappear—unless the click is inside the #formatting div's <button> elements.

  1. $("#textarea").focus(function() {
  2.       $('#formatting').slideDown(200);
  3. });

  4. $("#textarea").blur(function() {
  5.       $('#formatting').slideUp(200);
  6. });
I was thinking about using an if statement, but can't seem to make it work.

Any ideas would be very appreciated.

Cheers.