In this tutorial, We will learn how to get the x and y positions of an element on a click event?. We will learn to get the x y position of an element with jquery.

Let's learn by example:

<!DOCTYPE html>
        <title>jquery example</title>
        <script src="" crossorigin="anonymous"></script>
        <span>see the result in the console</span>
        <img id='image' src='' />
    <script type="text/javascript">
        $(document).ready(function () {
            $("#image").click(function (e) {
                var offset = $(this).offset();
                var x = e.clientX - offset.left;
                var y = e.clientY -;
                console.log("X:" + x + " Y:" + y);

Now, You can run your application and see the result.

Thanks, May this example will help you...

Are you facing problems in understanding this article?
You can watch the video. Watch it now