PDA

View Full Version : close div onclick


scroots
08-28-2002, 09:02 PM
i have a floating image in a div which is called by a click of a button, and changes when other buttons are pressed and when the user clicks on the page anywhere other than a button i want it to hide the div. to close the div the function is called "closediv"

can anyone help me?

scroots

beetle
08-28-2002, 09:14 PM
<script>
function checkClick(e) {
var obj = e.srcElement;
if (obj.id != "divID")
document.getElementById('divID').style.display = 'none';
}
</script>

<body onClick="checkClick(event)">Just replace divID with the actual ID of yor DIV, and you're set

scroots
08-28-2002, 10:12 PM
thank you beetle, its solved my problem.

scroots