Reputation: 11824
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 =)
});
Upvotes: 0
Views: 244
Reputation: 123377
$("#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
Upvotes: 3