javascript – Beginner: Get numeric value outside the offsetX value

So I'm trying to solve an equation that involves an interaction of the action and the movement of the click / touch of the mouse. It works quite like a slider, but it will make an animation run frame by frame, that's why I just need the numbers.


Every time I write the code below I can get the numbers to show and update live in the HTML, but I need the actual values ​​in the "minus" operation for the animation box control

                * post-initial function () {
var posX = event.offsetX;
document.getElementById ("Z"). innerHTML = posX;
}; *

Can someone please save me?