I'm trying to do something like submenu on input click and close it on losing focus with jQuery. Only accomplished using mouseup like this:
$(document).mouseup(function (e){
   var container = $(".container");
   if (!container.is(e.target)
       && container.has(e.target).length === 0
       && !$(".input").is(e.target))
   {
       $('.submenu').removeClass('submenu');
   }
});
here is my results: http://jsfiddle.net/Lwfhbdmp/8/
this works OK, but I think it's too complex and maybe there is a simpler solution for this? Please help.
 
     
    