jQuery: Position of the mouse pointer
jQuery Events : Exercise-9 with Solution
Find the position of the mouse pointer relative to the left and top edges of the document.
Solution :
HTML Code :
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>Find the position of the mouse pointer relative to the left and top edges of the document</title>
</head>
<body>
<div id="doc"></div>
</body>
</html>
JavaScript Code :
$( document ).on( "mousemove", function( event ) {
$( "#doc" ).text( "pageX: " + event.pageX + ", pageY: " + event.pageY );
});
Live Demo:
See the Pen jquery-events-exercise-9 by w3resource (@w3resource) on CodePen.
Contribute your code and comments through Disqus.
Previous: Change the background color of the <div> element of the following code on clicking the button.
Next: Stop people from writing in first text input box (user ID).
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join