title: Access table.id in JavaScript
body: <p>I have a webpage, which has a number of <a href="http://www.w3schools.com/aspnet/control_table.asp" rel="nofollow">ASP.NET tables</a>.</p>
  
  <p>The tables are defined on the server as follows (id is unique for every table):</p>
  
  <pre><code>dim tblOutput as table
  tblOutput.ID = id
  </code></pre>
  
  <p>I am trying to loop through all the tables on the webpage using JavaScript on the client as follows:</p>
  
  <pre><code>var trs = document.getElementsByTagName("table"); 
  for (var i = 0; i &lt; trs.length; i++) {
      var res2 = trs[i].attributes("id")
      alert(res2[i].id)
  }
  </code></pre>
  
  <p>The alert always prints 'undefined'.  I have debugged using firefox and id is always empty ("").  What am I doing wrong?</p>