get x and y axis on click jquery

Using jquery offset, we will determine the coordinates of the click in our specified div

by aljon254

HTML

<div class="axisXY" style="text-align:center;">
		Axis
	</div>
	<div id="layoutSpace">
    </div>

CSS

#layoutSpace{
			width:450px;
			height:450px;
			background:#F4F4F4;
			margin:auto;
		}

JavaScript

$('#layoutSpace').click(function(e){			 
    var offset = $(this).offset();  
    mouseX = (e.pageX - offset.left );
    mouseY =  (e.pageY - offset.top );			
    $('.axisXY').html("X: " + mouseX + " Y: " + mouseY);
});