This example shows, how to detect mouse x and y axis on the page and display mouse position on the screen using jQuery.
Here’s is a solution.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Detect mouse X and Y axis using jQuery</title>
<script src="http://code.jquery.com/jquery-1.4.3.min.js" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function () {
$(this).mousemove(function (e) {
$("#<%=Label1.ClientID %>").html("x-axis:" + e.pageX + " <br> y-axis:" + e.pageY);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Detect mouse X and Y axis using jQuery</h2>
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Download
DetectMousepostion.zip (908.00 bytes)
Live demo