5

Fairly easy yet i did not find how to do this online.

I want the first TD of the this element (row)

$(document).on("click", "#posTable tr", function() { 

    alert($(this).('td:first').text());

});

i tried:

alert($(this).('td:first').text());
alert($('td:first', $(this).parents('tr')).text()));
Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
Faarbhurtz
  • 550
  • 1
  • 8
  • 27

1 Answers1

7

You need to use find() to get the first td in the given row. You can also pass this in selector as a context.

Using find()

alert($(this).find('td:first').text());

Using jQuery( selector [, context ] )

alert($('td:first', this).text());
Adil
  • 146,340
  • 25
  • 209
  • 204