-5

Say I have a div that is 200px wide, I want after I click for example in the middle to log in the console 100px, and so on (If i click 20px to the right of the left edge I would like to log 20 for example)

Is this possible and any pointers?

dzumla011
  • 592
  • 3
  • 7
  • 20

1 Answers1

0

http://jsfiddle.net/KrJ7b/

$('#mydiv').on('click',function(e){
      console.log(e.clientX - $(this).offset().left);    
});
A. Wolff
  • 74,033
  • 9
  • 94
  • 155