I have a div and want to hide it when I click outside. My code is:

&lt;div id="mydiv"&gt;The div must be above button&lt;/div&gt;

    $('#mydiv').click(function(e) {
        e.stopPropagation();
    });

    $(document).click(function() {
        $('#mydiv').fadeOut(300);
    });


But it is not working for me ...

UPDATE

Full code is presented below. When I click on a button it shows a div above, so I need to hide this div when I click outside.

DEMO

&lt;div id="but" style="text-align: right;"&gt;&lt;button type="button"&gt;Show Div!&lt;/button&gt;&lt;/div&gt;
&lt;div id="mydiv" style="display:none;"&gt;The div must be above button&lt;/div&gt;

$("#but button").click(function(){
  var pos = $(this).offset(),
      div = $("#mydiv");

  // Make it visible off-page so
  // we can measure it
  div.css({
    "display": "block",
    "border": "1px solid black",
    "position": "absolute",
    "left": -10000,
    "top": 0
  });

  // Move it where we want it to be
  div.css({
    "left": pos.left - 40,
    "top":  pos.top - div.height() - 10
  });
});

$('#myDiv').click(function(e) {
    e.stopPropagation();
});
$(document).click(function() {
    $('#mydiv').fadeOut(300);
});



Question: How does one build a mizbeah?
Answer: 
  Are there specifications to build a Mizbeah?


Yes, there are specification for building a Mizbeach - and the Rambam has codified them in the first 2 chapters of הלכות בית הבחירה


  Can one build a Mizbeah in our days?


The Rambam (ibid 1:3) says that after the temple was built (i.e. nowadays), individuals may no longer have their private temples nor make private sacrifices.


  כֵּיוָן שֶׁנִּבְנָה הַמִּקְדָּשׁ בִּירוּשָׁלַיִם נֶאֶסְרוּ כָּל הַמְּקוֹמוֹת כֻּלָּן לִבְנוֹת בָּהֶן בַּיִת לַה' וּלְהַקְרִיב בָּהֶן קָרְבָּן


That leaves the option of building the Mizbeach on the Temple Mount. Two issues arise.


The Rambam says (ibid 1:4) we don't have enough details to build the 3rd Temple.



  וְכֵן בִּנְיָן הֶעָתִיד לְהִבָּנוֹת אַף עַל פִּי שֶׁהוּא כָּתוּב בִּיחֶזְקֵאל אֵינוֹ מְפֹרָשׁ וּמְבֹאָר



The Rambam says (ibid 2:1) that the Mizbeach must be built on its precise location; no deviation allowed.



  הַמִּזְבֵחַ מְקוֹמוֹ מְכֻוָּן בְּיוֹתֵר. וְאֵין מְשַׁנִּין אוֹתוֹ מִמְּקוֹמוֹ לְעוֹלָם


Building it nowadays would require deciding between various opinions as to its location. A job best left to Eliyahu HaNavi, may he arrive speedily in our lifetime.