On mouseout from float div hide but not from the main div

On mouseout from float div hide but not from the main div

Hi, i am baby to jquery, this is my first try.

I want when the user mouseout  from a drop menu to hide.
I have made it to a point but the menu disappears when it is out of the main div not the new one appearing.

Here is the html

  1. <div class="notifications">
  2. <button class="btn btn-primary" type="button">
  3.   Notifications <span class="badge">2</span>
  4. </button>

  5.   <div class="messages">
  6.     <a href="#" class="message">This is a message</a>
  7.     <a href="#" class="message">This is a message</a>
  8.   </div>
  9. </div>
  10. </div>
Here is the jquery
  1. $(function() {
  2.   $(".notifications .messages").hide();
  3.   $(".notifications").click(function() {

  4.     if ($(this).children(".messages").children().length > 0) {
  5.       $(this).children(".messages").fadeToggle(300);
  6.     }

  7.   });
  8. $(".notifications  .messages").mouseout(function() {

  9.    $(".notifications  .messages").hide();

  10.   });
  11. });
and the css if needed

  1. .notifications {
  2.   display:block;
  3.   background-color:white;
  4.   border-radius:50%;
  5. }

  6. .notifications .toggle {
  7.   display:block;
  8.   position:absolute;
  9.   width:100%;
  10.   height:100%;
  11. }

  12. .notifications .toggle:before,
  13. .notifications .toggle:after {
  14.   content:'.';
  15.   display:block;
  16.   position:absolute;
  17.   left:35px;
  18.   width:10px;
  19.   background-color:#bdc3c7;
  20.   color:transparent;
  21.   border-radius:5px;
  22. }


  23. .notifications .messages {
  24.   display:block;
  25.   position:absolute;
  26.   top:50px;
  27.   left:0px;
  28.   width:240px;
  29.   max-height:240px;
  30.   
  31. }

  32. .notifications .messages:before {
  33.   content:'.';
  34.   display:block;
  35.   position:absolute;

  36.   left:0px;
  37.   top:-18px;
  38.   width:0;
  39.   height:0;
  40.   color:transparent;
  41.   border:10px solid black;
  42.   border-color:transparent transparent white;
  43. }

  44. .notifications .messages .message {
  45.   display:block;
  46.   position:relative;
  47.   padding:10px;
  48.   background-color:white;
  49.   color:black;
  50.   text-decoration:none;
  51. }

  52. .notifications .messages .message + .message {
  53.   border-top:1px solid #e0e0e0;
  54. }



Any help is valuable.
I am happy learning such language , i know php and jquery is so necesery those days :)