Get the event location in jQuery
Event location
The following code prints out the event location by using the pageX and pageY properties.
<html>
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){<!-- www . j a v a 2s . c o m-->
$("div").mouseover(function(e){
var pageCoords = "( " + e.pageX + ", " + e.pageY + " )";
var clientCoords = "( " + e.clientX + ", " + e.clientY + " )";
$("span:first").text("( e.pageX, e.pageY ) - " + pageCoords);
$("span:last").text("( e.clientX, e.clientY ) - " + clientCoords);
});
});
</script>
</head>
<body>
<body>
<div>
<span>Move the mouse over the div.</span>
<span> </span>
</div>
<div>java2s.com</div>
</body>
</html>