uzhas
uzhas

Reputation: 925

How to clearListener if that addEventListener exists?

How can i remove listener but first to check if that listener exists?

       var listener1 = google.maps.event.addListener(markerR, 'click', function 

        (m) {
         if(exist) 
google.maps.event.clearListeners(listener1);

        });

Upvotes: 0

Views: 2588

Answers (2)

I dont think there is a way to check if an EventListenner exists in js. All though you can make a variabel and save to this everytime you add an EventListener.

Upvotes: 2

Kenneth Voss
Kenneth Voss

Reputation: 49

You should be able to like

if(element.hasOwnProperty('onclick'))...

Upvotes: 0

Related Questions