Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<div class="position">Hello</div><br/><br/>
<div >
  <div>
    <div>
      <a id="test">
  <img class="demo-box" src="http://www.degordian.com/static/img/shareImg/degordian.png" />
      </a>
    </div>
    </div>
</div>
<br/><br/>Hello again<br/><br/>
<div >
  <img class="demo-box" src="http://www.degordian.com/static/img/shareImg/degordian.png" />
  
</div>
 
$(function() {
$("#test").click(function(e) {
  var offset = $(this).offset();
  var relativeX = (e.pageX - offset.left);
  var relativeY = (e.pageY - offset.top);
  alert(relativeX+':'+relativeY);
  $(".position").val("afaf");
});
});
   
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers