获得此行的第一个TD

问题描述:

相当简单,但我没有找到如何在线进行此操作。

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

我想要这个元素的第一个TD(行)

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

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

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

});

我试过:

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


你需要使用 find() 获取给定行中的第一个td。你也可以在选择器中传递 this 作为上下文。

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

使用 find()

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

使用 jQuery(selector [,context])

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