user1160126 user1160126 - 9 months ago 27
Javascript Question

on click show div getting error

am very sorry for this new bie question, when i click on the lick the div should open when i click again it should close the div..please help me on this

<script type="text/javascript">
var bool = 0;
function showDiv(){
document.getElementById(show).style.visibility = "hidden";
}else if(bool==0){
document.getElementById(show).style.visibility = "visible";
<input type="button" value="click" onclick="showDiv();" />

<p>it is okay it is okay it is okay it is okay it is okay it is okay it is okay it is okay</p>



You're missing the quotes for the id argument for getElementById()

document.getElementById('show').style.visibility = "hidden";

Also the id attribute name is missing on the <div>


Should be this:

<div id="show">