获得此行的第一个TD
相当容易,但我没有找到如何在线这样做。
我想要这个元素的第一个TD(行)
$(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。 您也可以在选择器中将其作为上下文传递。
使用find()
alert($(this).find('td:first').text());
使用jQuery(selector [,context])
alert($('td:first', this).text());