Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<div class="outer">
  <div class="inner">
    
  </div>
</div>
</body>
</html>
 
div.outer{
  border:1px solid;
  height:150px;
  width:150px;
}
div.inner{
  border:1px solid;
  height:50px;
  width:50px;
  margin:auto;
}
 
$("div.inner").on('click',function(e){
//code block start
var parentOffset = $(this).parent().offset(); 
var relX = e.pageX - parentOffset.left;
var relY = e.pageY - parentOffset.top;
console.log(relX);
console.log(relY);
//code block end
  
setTimeout(function(){
//inserting code block here
},200);
});
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
trivenderpro
0viewers