title: How to fix Cannot read property 'currentTarget' of undefined error
body: <p>At 'currentTarget', i get an error when i run my code. </p>
  
  <p>I have tried researching the problem but i cant find anything that works </p>
  
  <pre><code>// London is active by defult
  document.getElementById("London").style.display = "block";
  event.currentTarget.className += " active";
  
  function openCity(cityName) {
  
    // Get all elements with class="tabcontent" and hide them
    let tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i &lt; tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
    }
  
    // Get all elements with class="tablinks" and remove the class "active"
    let tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i &lt; tablinks.length; i++) {
      tablinks[i].className = tablinks[i].className.replace("active", "");
    }
  
    // Show the current tab, and add an "active" class to the button that opened the tab
    document.getElementById(cityName).style.display = "block";
    event.currentTarget.className += "active";
  }
  </code></pre>
  
  <p>index.js:12 Uncaught TypeError: Cannot read property 'currentTarget' of 
  undefined  at index.js:12</p>