title: when do we need to call prevent default in javascript?
body: <p>i attach a event listener on click event, to few list items. in my function click_handler below, before i do anything , i call e.preventDefault(). but i'm not sure if i need this here. i understand that this call prevents any default action, but i'm still not sure when do we need it or not. in this case, when these items are clicked, i do want to open the urls associated with it in a new tab, and also do pass some data to google analytics script. </p>
  
  <p>html</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li&gt;&lt;a class='linkitems' href="..."&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class='linkitems' href="..."&gt;&lt;/a&gt;&lt;/li&gt;
  ...
  &lt;/ul&gt;
  </code></pre>
  
  <p>js file </p>
  
  <pre><code>document.getElementsByClassName("linkitems").addEventListener("click", click_handler);
  
  function click_handler(e) {
     e.preventDefault();
  
     //pass link data for google analytics
  }
  
  </code></pre>