I want to record x coordinates in the following situation
when mouse is pressed down i should get X1 and if mouse is moved keeping button pressed and then when it is unpressed at that time X2
i can detect mouse down and mouse up events but not sure how to do it what i want
This function demonstrates the general idea in modern, standards-compliant web browsers but there are many details (such as cross-browser awareness, the scroll view, etc.) that might be better handled with a framework such as jQuery:
Note that you’ll also want to check for “mousemove” events in between the “mouseup”/”mousedown” in case the latter two events happen to occur at the same location.