Friday, January 23, 2015

Get axis on click jquery

get x and y axis on click using jquery

We will use jquery offset to determine the coordinates of the click in our specified div
$('#layoutSpace').click(function(e){    
    var offset = $(this).offset();  
    mouseX = (e.pageX - offset.left );
    mouseY =  (e.pageY - offset.top );   
    $('.axisXY').html("X: " + mouseX + " Y: " + mouseY);
});

LIVE DEMO click anywhere on the box

No comments:

Post a Comment