title: Javascript prevent default onclick in code
body: <p>I know that i can do </p>
  
  <p><code>&lt;element onclick(function(event))&gt;&lt;/element&gt;</code></p>
  
  <p>but how can i pass event to fuction using just code</p>
  
  <pre><code>document.getElementById('elementId').onclick = function(){event.preventDefault()}
  </code></pre>