JSFiddle - React, Tailwind, and code Playground
HTML
Here is the example:
<div id='example'>Click this div</div>
CSS
#example {
cursor: pointer;
background-color: #DDD;
width: 100px;
height: 100px;
}
JavaScript
var element = document.getElementById('example')
element.onclick = function(e) {
var x = e.pageX - element.offsetLeft
var y = e.pageY - element.offsetTop
alert('x : ' + x + ', y : ' + y)
}