Nika Jobava
Nika Jobava

Reputation: 138

Click event stops mousemove and can't continue

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

Answers (1)

Addison Schmidt
Addison Schmidt

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

Related Questions