Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:47:15+00:00 2026-06-08T01:47:15+00:00

Possible Duplicate: getting the X/Y coordinates of a mouse click on an image with

  • 0

Possible Duplicate:
getting the X/Y coordinates of a mouse click on an image with jQuery

I want to calculate clicked position of a image, lets say this will be an example:

enter image description here

And if I would click on it somewhere, I want to display an alert with the X/Y position of the clicked area on the image, there are pixels on the images, so it should display x pixel offset and y pixel offset.

Is that possible to do with the Javascript? Any examples would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:47:17+00:00Added an answer on June 8, 2026 at 1:47 am

    Using JQuery, use the pageX and pageY values of the event to which you substract to the offset of the element.

    http://jsfiddle.net/BramVanroy/D63KS/1/

    $(document).ready(function(){
        $('img').mousedown(function(e){
            var offset = {
                x: e.pageX - $(this).offset().left,
                y: e.pageY - $(this).offset().top
            }
                $('#info').html('{'+offset.x+'; '+offset.y+'}');
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Getting mouse position in c# Is it possible to mimic a peripheral
Possible Duplicate: Getting specific days in a month I've touched on this problem once
Possible Duplicate: Getting the ID of the element that fired an event using JQuery
Possible Duplicate: Getting JavaScript object key list How to iterate json data in jquery
Possible Duplicate: getting identity row value using ADO.NET Entity This is my example code:
Possible Duplicate: Getting the ID of the element that fired an event using jQuery
Possible Duplicate: Learning jQuery and Getting Better at Javascript I have found jQuery very
Possible Duplicate: Getting jQuery-inserted DOM elements without requerying for element after insertion Is there
Possible Duplicate: Getting exception as “Collection was mutated while being enumerated” This question is
Possible Duplicate: Getting Dates between a range of dates Let's say I have 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.