I am using jQuery.post to perform an action when a user clicks an external link. I've attached an onClick event to the link:
<a id="lib-geo57" onClick="javascript:dConvert('lib-geo','57');"
The event fires, however this action should only be performed once. To avoid a second firing, I thought of removing the onClick attribute:
function dConvert(a,k){
$.post("dConverter",{aid:a,key:k});
$("#"+a+k).removeAttr('onclick');
};
but that doesn't work. I also tried
$("#"+a+k).attr('onclick','');
without success. The post function continues to work in both of the above examples.
Why can't I remove or change the onClick attribute? What would be a better strategy to prevent my post from executing more than once?