Is it possible to change which onclick javascript function is executed after an anchor is clicked?
Example:
<a id="myLocation" class="locator" href="#" onclick="javascript:getMyLocation();"> My Location</a>
When the user clicks this anchor their location is displayed on a map with a marker.
I want the onclick to change to RemoveLocation() now so that when they click the anchor again is removes the marker for their location on the map.
getMyLocation() and RemoveLocation are already written I just need to change the onclick event after a user clicks the anchor, if possible.
Add this to your
getMyLocation()function:And in the
RemoveLocation()function: