Hi, I am very new to javascript and html.
I am trying to create a function which will hide or show a div (div1). Right now, it is always showing the div whether the boolean value is true or false. I know that it is getting inside the else if part, but it doesn't seem to be working.
Code:
<script type="text/javascript">
function hideDiv(flag)
{
if (flag == false)
{
document.getElementById('div1').style.visibility="visible";
}
else if (flag == true)
{
document.getElementById(div1).style.visibility="hidden";
}
}
var bool = new Boolean(true)
hideDiv(bool);
</script>
<body>
<div id="div1">
Text!
</div>
</body>
Thank you for taking a look