Menu outside click hide

HTML

<div id="menu">saa</div>

<div id='panel'>[Put your content here]</div>
<input type="button" id='click' value="Show/Hide" />

CSS

#menu {
    width:200px;
    height:150px;
    background-color:red;
}

#panel
{
     height: 200px;
     width: 200px;
     background: #E88C37;
     float: left;
     display: none;
     font-size: xx-large;
}

JavaScript

$(document).on('click', function(event) {

if (!$(event.target).is('#menu')) {
// Hide the menus.
   $('#menu').hide();
}
});
    
    //
    $('#click').click(function()
{   
    $("#panel").toggle();     
});