I am trying to prevent the default action on the binding ("a"). In my script, several html lines are displayed on the fly using ajax (after submitting the form), and I want to add an event listener that
Here is what I am writing:
a = document.getElementById("new_link");
a.addEventListener("click",function(){alert("preform action");
return false;},false);
I also tried:
a.addEventListener("click",function(e){e.preventDefault(); alert("preform action");});
When I click on the βaβ link, it shows a warning, but still opens the βhrefβ link, where I want it to display a message and then stop.
Both methods show alerts if they are tied to an existing link, but do not work when connected to newly inserted links (via ajax). This is what I need to do.
Any help / suggestions.
Thank.