【发布时间】:2013-10-14 10:38:38
【问题描述】:
我有这个 jQuery 选择器:
'table tbody tr td:first-of-type'
如何从 $(this) 为同一行构造一个单元格选择器?我需要检查
$(document).on('click','table tbody tr td:first-of-type',function()
{
if ( $('table tbody tr td:nth-child(2)').text() != "" ) // for the same row !!
//do something
else
//do something else
}
额外的问题:我应该避免使用像 nth-child() 这样的 CSS3 选择器并使用像 eq() 这样的 jquery 选择器吗?
【问题讨论】:
-
您能发布一些 HTML 和您想要实现的示例吗?您的问题并不完全清楚。
-
您在选择器中忘记了一些
',是拼写错误吗?应该是if( $('table tbody tr td:nth-child(2)').text() != "" ) -
@Sergio 是的,只是错字
标签: jquery html-table jquery-selectors