Javascript function takes 2 click to fire

AngelxD

New Member
i have a javascript function to open and close a modal it checks if the modal is open and closed but it takes 2 clicks the first time to fire off until you refresh the page then you have to click 2 time again.Javascript: \[code\]function ToggleModal(Box) { var Modal = document.getElementById(Box); var Display = Modal.style.display; if(Display == 'none') { Modal.style.display = 'block'; document.getElementById('Wrapper').style.overflow = 'hidden'; } else { Modal.style.display = 'none'; } }\[/code\]CSS:\[code\].Modal { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-image: url("../IMG/Modal.png"); background-repeat: repeat; z-index: 2000;}\[/code\]my div:\[code\]<div id="Login" class="Modal"> <div id="LoginForm" class="Form"> <div class="ModalTitle">Sign In <a href="http://stackoverflow.com/questions/15914450/#" class="Toggle" onclick="ToggleModal('Login');"></a></div> <div class="ModalBody"> <form id="LForm" action="/Assets/PHP/Login/Login.php" method="POST"> <label for="User">Username:</label> <input id="User" type="text" name="User" class="Input" placeholder="Username" /> <label for="Pass">Password:</label> <input id="Pass" type="password" name="Pass" class="Input" placeholder="Password" /> </form> <div class="Clear"></div> </div> </div></div>\[/code\]there are no styles for the Logo div id.
 
Top