click Triggers after mousedown and then mouseup over the same element if the left mouse button was used. mousemove Every mouse move over an element triggers that event. mouseover/mouseout Mouse pointer comes over/out from an element. In this example, I put the X- and Y-coordinate values in an input box, but you can tweak that to fit your needs.ĭocument.getElementById('cursorX').value = (window.Event) ? e.pageX : event.clientX + ( ? : ) ĭocument.getElementById('cursorY').value = (window.Event) ? e.pageY : event.clientY + ( ? : document.body. Mouse button is clicked/released over an element. The JavaScript script presented in this page can be used to Get Mouse coordinates inside a HTML element, usually a Div or an Image. The clientX property returns the horizontal coordinate (according to the client area) of the mouse pointer when a mouse event was triggered. I checked my function thoroughly but I didn't find the bug. ![]() ![]() ![]() The Javascript code below provides a sample of how the user’s mouse cursor position, displayed as X- and Y-coordinates in relation to the top left corner of the page. I created a small function to get mouse coordinates in div but somehow it is not working.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |