Dropdown menu with clickout

Dropdown menu with clickout

I'm trying to achieve this effect by putting a full page big background div with z-index lower than the one of the dropped down menu.

With this code:
$("li.lang").click(function () {
     
      $("#backgroundSelect").show();
      $("#select").show();
     
  });
  $("#backgroundSelect").click(function(){
      //$("#selectlang").hide();
      alert("hide!");
      //$("#backgroundSelect").hide();
     });


I can click on my li.lang, the dropdown menu (#select) is showed, the background too (I made it totally white to try), then I click outside the div #select and they don't hide. I can't even display that alert.

I really can't see what the problem is, since I use it already on another page (although a bit more complicated). Help?

Thanks