title: Can't get the name of a column from an HTML Table
body: <p>I have tried so bad with no luck to get the name of a column of a table by using Javascript. I just want to get the text inside a th tag:</p>
  
  <pre><code>&lt;th data-visible="false" id="th-0"&gt;The column name&lt;/th&gt;
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>var columna = document.getElementById('th-'+key).innerHTML;
  </code></pre>
  
  <p>And I just get either the error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'innerHTML' of null
  </code></pre>
  
  <p>or nothing when I try</p>
  
  <pre><code>var column = $('#th-'+key).text();
  </code></pre>
  
  <p>The key var comes fro ma loop because I am using bootstrap table where i want to show additional information if the user clicks on a plus button:</p>
  
  <pre><code>function detailFormatter(index, row) {
      var html = [];
      var columns_number=document.getElementById('table').rows[0].cells.length;/*http://stackoverflow.com/a/10043799/1883256*/
      console.log('The number of columns is: '+columns_number);
      $.each(row, function (key, value) {
          if(!isNaN(key)){/*http://stackoverflow.com/a/9716580/1883256*/
           console.log('Key value is: '+key);                    
           var column = $('#th-'+key).text();
                  html.push('&lt;p&gt;&lt;b&gt;' + key + ':&lt;/b&gt; ' + value + ' - column: '+ column +'&lt;/p&gt;');
          }
      });
      return html.join('');
  }
  </code></pre>
  
  <p>Can anyone shed some light to fix this?</p>