Over a million developers have joined DZone.

Detecting Mouse Position

This is an easy way to determine the mouse position (click anywhere and the co-ordinates get displayed:


   Mouse co-ordinates

You can store them in form fields

x = y =

or as plain text

Of course knowing the co-ordinates also makes it possible to position elements based on the position of the mouse pointer. It will work for any mouse event Mouseover, mouseout, etc; just change click to the desired event in the final if statement of the script. More good stuff and articles at the home of real IT Mentors

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}