Reputation: 138
I want to make 2 divs to follow cursor, but click event stops the whole mousemove event an I can't continue even if I redefine EventListener again at the end of the click event function
document.addEventListener("mousemove", function () {
HL.style.top = `${event.clientY - 1}px`;
VL.style.left = `${event.clientX - 1}px`;
});
How can it be fixed?
Upvotes: 0
Views: 37
Reputation: 484
You're missing the event
function parameter. You want:
document.addEventListener("mousemove", function (event) {
HL.style.top = `${event.clientY - 1}px`;
VL.style.left = `${event.clientX - 1}px`;
});
Upvotes: 2