Jump to content

hide div when not clicking on it


sw45acp

Recommended Posts

Hi, I have the following javascript:

function createDiv() {
var newDiv = document.createElement("div");
newDiv.setAttribute("id","box");
document.body.appendChild(newDiv);
var box = document.getElementById("box");
}

and html:

<input type="button" value="Create Div" onclick="createDiv()" />

that creates a new div on the page. What I would like is for this div to completely disappear when a user clicks anywhere else on the page. What I mean can generally be seen on any javascript date picker/calendar for forms.

 

Any help is appreciated, thank you.

Link to comment
https://forums.phpfreaks.com/topic/197593-hide-div-when-not-clicking-on-it/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.