Clem Clem - 22 days ago 4x
Javascript Question

Table header JavaScript

My question is, how can I get text from header in javascript? So if I click on header I'll get alert with header text...

$("#myTable th").click(function() {
alert(this.text()); //that doesn't work =)

$("#myTable th").click(function() {
  alert($(this).text());  //use $(this)

text() is a jQuery method so you should apply it to a jQuery selector.
this, inside the function handler refers instead to the DOM node