Javascript removeEventListener not working

This is because that two anonymous functions are completely different functions. Your removeEventListener‘s argument is not a reference to the function object that was previously attached.

function foo(event) {
              app.addSpot(event.clientX,event.clientY);
              app.addFlag = 1;
          }
 area.addEventListener('click',foo,true);
 area.removeEventListener('click',foo,true);

Leave a Comment