【问题标题】:Get first TD of THIS row获取此行的第一个 TD
【发布时间】:2013-11-13 19:44:41
【问题描述】:

相当简单,但我没有在网上找到如何做到这一点。

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

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

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

});

我试过了:

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

【问题讨论】:

标签: javascript jquery html


【解决方案1】:

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

使用find()

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

使用jQuery( selector [, context ] )

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2023-03-22
  • 2021-10-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多