Why is dispatchEvent broken?
-
Well the point is this.
const event = new WheelEvent('docscroll') document.dispatchEvent(event) anotherElement.addEventListener('docscroll', function() {/* функция */})
I want other elements to know when the document is scrolling, but for some reason the document doesn't emit an event.JavaScript Adalyn Murray, Oct 17, 2020 -
You fire an event at the topmost level (document). Naturally, the elements below it will not see it.Anonymous
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!