Answer the question
In order to leave comments, you need to log in
Is there any way to remove the event handler inside the callback function immediately after execution?
element.addEventListener( 'mousedown', () => {
window.addEventListener( 'mouseup', () => {
//сделать что-то;
//а вот тут удалить обработчик на window, пока не будет сделан следующий клик на элементе
} );
} );
Answer the question
In order to leave comments, you need to log in
addEventListener and removeEventListener
const onClick = () => {
console.log("Hello World");
window.removeEventListener('click', onClick);
});
window.addEventListener('click', onClick);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question