Get event clientX clientY

Description

The following code shows how to get event clientX clientY.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--from   ww w .  j  a v a2s  . c  om-->
    $("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>
  <div>
    <span>Move the mouse over the div.</span> <span>&nbsp;</span>
  </div>
  <div>java2s.com</div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities