How to respond to a click outside a certain area?

My document looks like this: enter image description here

Basically, the background is a full-screen, transparent div. There are a couple of problems ... if I just create a background div and don’t apply any z-index to it, it is on top of everything and I can’t click on the field. If I set the z-index of the background div to be below the field, I cannot click on the background. I want to do this in order to be able to click on the field and the background.

var x = document.getElementById("bg");
x.addEventListener("click",reset,false);

function reset() {
   alert("reset was clicked");
}

COMPLETION: the field is at the same node level as in bg. it is not inside the bg div.

+5
source share
2 answers

, . Firefox Chrome. , . html, body { width:100%; height:100%; } , .

IE gif div , div .

0
+1

All Articles