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?
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?
$('#mydiv').on('click',function(e){
console.log(e.clientX - $(this).offset().left);
});