javascript - remove all links from within div -
i've embedded custom ggl map within container div using javascript (not google iframe), , div display map within first/original container div. need deactivate links within either div links in embedded map not clickable.
i've tried following jquery solution doesn't seem work:
<script> $("#map_canvas a").click(function(e) { e.preventdefault(); }); </script>
then i've tried following css solution blocks user's ability pan map.
pointer-events: none;
how can enable user interactivity map while preventing anchor links working within embedded map? thanks!
i guess first problem links created dynamically. so, when call $("#map_canvas a")
, there no a
elements bind to. might try delegated syntax of bind()
. assuming #map_canvas
exists when script called (and recommend putting code in ready
block):
$( function() { $('#map_canvas').on('click', 'a', function() { // return false preventdefault , stoppropagation in jquery return false; }); });
Comments
Post a Comment