I have made simple Javascript function for show and hide but unable to trigger outside click hide function.
HTML
<a href="javascript:void(0);" onClick="showhide()" class="btn" >click </a>
<div id="myID">
<p>Hello World</p>
</div>
CSS
.btn{
color:red;
border-radius:5px;
padding:10px;
display:inline-block;
}
#test{
display:none;
border:1px solid blue;
width:200px;
height:200px;
margin:10px
}
Javascript
function showhide(){
var div = document.getElementById("test");
if (div.style.display !== "none") {
div.style.display = "none";
}
else {
div.style.display = "block";
}
}
Please check this code here.
No jQuery please. Thanks