I have added an event listener to a progress bar. When I click on the bar I can get to a function. What I cannot figure out is how to find the horizontal location on the bar the click event occured. I wish to take this location to the target function so I can process it.
Take in note that pageX gives you an coordinate related to left edge of the page.
You may also want to convert it to the local coordinate (related to left edge of your progress bar).
You can use element.getBoundingClientRect().left for that.
Example:
If you’ll not do that, your script can behave differently depending on the element position on the page (for example that position can change if user shrinks the browser window).
PS: i replied to Felgall’s post, but this info is for OP. I’m sure Felgall knows that already