I am using simple html and inlay js + css to create a simple site that just tracks wether a worker is at work or not (by simply clicking on a td with their name), thing is I never worked with js and after a day of reading documentations and looking up stackoverflow and w3schools, I can't get my code running. My problem is whenever i try to click on a td the background color doesnt change and when I got a solution the whole table background color changed, but I want a single td at a time, can anyone help me? so far i got:
<script language=javascript type="text/javascript">
var el
function colCell() {
  if (typeof event !== 'undefined')
    el = event.srcElement;
  elements = document.getElementsByTagName('td');
  if (el.style.backgroundColor == "#E5F0F8")
  {
    el.style.backgroundColor = "#0066bb"
    el.style.color ="#ffffff"
  }
  else if (el.style.backgroundColor == "#0066bb") 
  {
    el.style.backgroundColor = "#ff00ff"
    el.style.color = "#ffffff"
  }
  else
  {
    el.style.backgroundColor = "#E5F0F8"
    el.style.color = "#000000"
  }
}
if (window.addEventListener)
  window.addEventListener('click', function(e) {
    el = e.target
  }, true)
</script>
With this table :
<div class="contentSection">
        <table class="awht2">
            <tr>
                <td colspan="5" class="line">LCS</td>
            </tr>
            <tr>
                <td onclick="colCell()" style="background-color: #E5F0F8;">
                    TestFarbe
                </td>
Consider the td and tr repeated a few times.
sorry for being so noob'ish this is my first project with js and html
 
     
     
    