javascript - Element on click changes google maps styles -


i'm trying change google maps' styles when user clicks anchor. accomplish this, i'm trying make simple alert work inside addlistener doesn't seem work.

html

<a href="" id="click-me">click me</a> 

js

...  google.maps.event.addlistener(document.getelementbyid('click-me'), 'click', function(){     alert('asdf'); });  ... 

what doing wrong?

obs 1: tried use preventdefault().

obs 2: anchor inside dom. isn't dynamically inserted.

if listener on dom element, use adddomlistener, not addlistener. change:

google.maps.event.addlistener(document.getelementbyid('click-me'), 'click', function(){     alert('asdf'); }); 

to:

google.maps.event.adddomlistener(document.getelementbyid('click-me'), 'click', function(){     alert('asdf'); }); 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -