0

For a progress bar of music, like youtube progress bar. I just want use this with a JS/JQuery.

For example, if I had this code:

<div style="pointer:cursor;width:250px;background:#cccccc">&nbsp;</div>

and lets say I click exact on the half of this div element,I want that JS returns 125px.Is there any way to do so?

Shoaib Chikate
  • 8,665
  • 12
  • 47
  • 70
  • This should help you: [getting the X/Y coordinates of a mouse click][1] [1]: http://stackoverflow.com/questions/2159044/getting-the-x-y-coordinates-of-a-mouse-click-on-an-image-with-jquery – Daco Dec 12 '13 at 12:58

1 Answers1

1

Try that:

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