I am looking to have a transparent div on an HTML page with a graphic on which it has instructions for the user on how to use the page. When anywhere on the page is clicked or pressed then the div will hide/disappear.
I have JavaScript code which I have taken from another post on Stack Overflow, but I cannot seem to get it working.
It is linked to my HTML page and CSS, and the div is appearing, but it isn't disappearing when clicked.
How can I do this?
HTML code is as below:
<div id="overlay">
<div id="home_text">
<!-- Your image -->
</div>
</div>
CSS:
#overlay {
background: rgba(0, 0, 0, .4);
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
z-index: 10;
}
#home_text {
background: red;
height: 300px;
margin: 20px auto 0;
width: 300px;
}
JavaScript:
(function () {
var overlay = ('#overlay');
overlay.on('click', function (e) {
overlay
.hide()
.off();
});
});