Benny Sutton is 4 hire - just click here

Get Mouse Coordinates with Javascript

How do you get the position of the mouse with javascript? Like this.

simply add an event listener to your element (could be the window but here is just a div with an id of icontainer).

        document.getElementById("icontainer").addEventListener("mousemove", function (event) {

            var x = event.clientX;
            var y = event.clientY;
            var coo = "X and Y axis: " + x + "," + y;
            document.getElementById("position").innerHTML = coo;