JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<body>
<div id="bg">
</div>
<div id="box">
</div>
</body>
</html>
CSS
html, body {
width:100%;
height:100%;
}
#bg {
width:100%;
height:100%;
}
#box {
position:absolute;
top: 20px;
left: 100px;
width:100px;
height:100px;
background-color:blue;
}
JavaScript
var bg = document.getElementById("bg");
bg.addEventListener("click", clickBg, false);
var box = document.getElementById("box");
box.addEventListener("click", clickBox, false);
function clickBg() {
alert("Click on Background");
}
function clickBox() {
alert("Click on Box");
}