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 8425019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:09:43+00:00 2026-06-10T04:09:43+00:00

Possible Duplicate: jQuery get mouse position within an element I have a page and

  • 0

Possible Duplicate:
jQuery get mouse position within an element

I have a page and inside that page I have a div.
If the user clicks inside that div it’ll store the X/Y co-ordinates of where they clicked inside that div.

E.g. if I clicked in the top left corner of the div (no matter where the div was placed on the page) it’d return approximately 0, 0.

Is this even possible? and if so, could you tell me how – or even point me in the right direction?

  • 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-10T04:09:45+00:00Added an answer on June 10, 2026 at 4:09 am

    Use pageX property of the event to get the x coordinate relative to the page and pageY to get the y coordinate, then substract the element’s coordinates to get the position relative to the element.

    $( '#target' ).on( 'click', function( e ) {
        var x = e.pageX - this.offsetLeft;
        var y = e.pageY - this.offsetTop;
    });​
    

    Demo: http://jsfiddle.net/WhrFt/

    Official tutorial on jquery.com: http://docs.jquery.com/Tutorials:Mouse_Position

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: getDate with Jquery Datepicker I have a registration page inside that I
Possible Duplicate: How to get nth jQuery element I have this simple code: <ul>
Possible Duplicate: Get Class List for Element with jQuery If I have something like
Possible Duplicate: how to get GET and POST variables with JQuery? I have the
Possible Duplicate: jQuery: how do I animate a div rotation? I have a div
Possible Duplicate: jQuery AJAX submit form I have a form on a page A,
Possible Duplicate: How to get the mouse position without events (without moving the mouse)?
Possible Duplicate: How to show/hide a div on mouseover using jquery? I have a
Possible Duplicate: how to get the value of a textarea in jquery? I have
Possible Duplicate: How to get all options of a select using Jquery? I have

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.