Javascript Mouse Position

How To Get Mouse Position Using Javascript

Javascript Mouse Coordinates



In This Javascript Tutorial we will see How To Get And Show The Cursor Coordinates On The Mouse Moving Event Or onClick And Display X And Y  Using JS In Netbeans Editor .




Project Source Code:

<!DOCTYPE html>
<html>
    <head>
        <title>Javascript - Mouse Position</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>

        <p id="position">Test</p>

        <script>
            
            document.addEventListener("mousemove",function(event){
                
                var x = event.clientX;
                var y = event.clientY;
                
                document.getElementById('position').innerHTML = " X = "+ x +"][ Y = "+ y;
                
            });
            
        </script>

    </body>
</html>




Share this

Related Posts

Previous
Next Post »