title: how to change color of column in html table using javascript
body: <pre><code>window.onload = function () {
      var tbl = document.getElementById('tbl');
      var tr = tbl.getElementsByTagName('tr');
      for (var i = 0; i &lt; tr.length; i++) {
          var first_td = tr[i].getElementsByTagName('td')[0];
          first_td.onmouseover = function () {
              hover('on');
          }
          first_td.onmouseout = function () {
              hover('off');
          }
      }
      function hover(state) {
          for (var i = 0; i &lt; tr.length; i++) {
              var first_td = tr[i].getElementsByTagName('td')[0];
              if (state == 'on') {
                  first_td.style.color = 'White';
                  first_td.style.background = 'RED';
              }
              else if (state == 'off') {
                  first_td.style.color = '#000';
                  first_td.style.background = '#fff';
              }
          }
      }
  }
  </code></pre>
  
  <p>I do this but this code not working for all table column. in this code there only any one column are worked. other column are not working. please provide the code for the change all the column change color on hover.</p>