prevent default link action with addeventlistener
<pre><code>&lt;a id="link" href="example.com"&gt;test&lt;/a&gt;

var a = document.getElementById(link);
a.addEventListener('click',function(e){
//code
}, false);
</code></pre>

<p>How can I prevent the link action to go to example.com?</p>