Out of interest, I tried to write a range slider to understand how this should work, but I ran into a problem:
var slider = document.querySelector('.slider'); var button = document.querySelector('.button'); slider.addEventListener('mousemove', function(e) { var lg = document.querySelector('.cursor'); lg.innerHTML = 'Координаты мыши: ' + e.offsetX; }); .slider { background: blue; height: 30px; width: 500px; } .button { background: red; height: 30px; width: 30px; margin-left: 96px; } <div class="slider"> <div class="button"></div> </div> <hr> <div class="info"> <span class="cursor"></span> </div> It should work like this: I move the cursor over the slider block, and the mousemove event mousemove moves the button block.
The problem is that when you hover over a button block, an event occurs on it. Is there a way to ignore hovering on a button while continuing to generate an event on the slider ?
If not, in what other way should the button block be moved inside the slider ?