Is it possible to determine the value/position of a user\'s click on a progress bar using plain javascript?
Currently, I can detect a click on the element but can only g
The click
event actually takes a parameter that includes event information including the click position information. You can use this to determine where in the progress bar the click occured.
document.getElementById('progressBar').addEventListener('click', function (event) {
document.getElementById('result').innerHTML = ('Current position: ' + document.getElementById('progressBar').position + "
");
document.getElementById('result').innerHTML += ('Current value: ' + document.getElementById('progressBar').value + "
");
document.getElementById('result').innerHTML += ('Mouse click (absolute): ' + event.offsetX + ", " + event.offsetY + "
");
});