JSFiddle - React, Tailwind, and code Playground
by Barry Margolin
HTML
<p><h3>Click count:<span id="output">
</span></h3></p>
<h3>Click locations:</h3>
<div id="clickLocations"></div>
<input id="btn" type="button" value="Validate">
JavaScript
$(document).ready(function() {
var count = 0;
$("body").click(function (event) {
count += 1; //Count clicks when the body is clicked
if (count > 0) {
$("span#output").html(" " + count);
$("div#clickLocations").append("<ul><li>" + event.pageX + ", " + event.pageY + "</li></ul>"); //Display the x,y location of the click
}
}); //End body.click
$('#btn').click(function (event) { //Clear text when the button is clicked
$("div#clickLocations").html('');
$("span#output").empty();
event.stopPropagation();
}); //End button.click
}); //End document.ready