document.onclick = function(){
alert('test')
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<div class='div1'>test</div>
</body>
</html>
.div1{
width: 200px;
height: 200px;
background-color: red;
}