×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: wang yi
Added: Mar 30, 2017 4:27 PM
Views: 6
Tags: jquery mouse
  1. $(function() {
  2.  $("#demo-box").click(function(e) {
  3.  
  4.   var offset = $(this).offset();
  5.   var relativeX = (e.pageX - offset.left);
  6.   var relativeY = (e.pageY - offset.top);
  7.  
  8.   alert("X: " + relativeX + "  Y: " + relativeY);
  9.  
  10.  });
  11. });