<h2>Click outside div will be hide. Click Button div will be display</h2>
<button onClick="document.getElementById('pol').style.display='block'">Show</button>
<div id="pol">
I am Tanmoy Biswas
</div>
h2{margin:0 0 10px}
#pol{
width:400px;
height:300px;
background:#999;
text-align:center;
display:none;
margin-top:0;
margin:10px;
}
window.addEventListener('mouseup',function(event){
var pol = document.getElementById('pol');
if(event.target != pol && event.target.parentNode != pol){
pol.style.display = 'none';
}
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.