jQuery - Select first cell of a given row?

后端 未结 2 581
悲哀的现实
悲哀的现实 2021-02-05 00:59

I have a table with images in one column. When I click the image, would like to get the text value of the first column in that row.

I can get the whole row with this:<

相关标签:
2条回答
  • 2021-02-05 01:40

    How about?

    var a = $('td:first', $(this).parents('tr')).text();
    
    0 讨论(0)
  • 2021-02-05 01:51

    Here's another option:

    var a = $(this).closest('tr').find('td:first').text();
    
    0 讨论(0)
提交回复
热议问题