繁体   English   中英

jQuery获取表的所有第一个单元格

[英]jQuery Get All First Cells Of Table

我需要获取某个表中所有行的所有tds(单元格),是否有一种优雅的方法来执行此操作,或者我需要以某种方式自己遍历集合?

尝试first-child

 $('table tr td:first-child')
 or
 $("table tr td:first")
 or
 $("table tr td").first()

此代码将返回表中所有id为tableId的tds

$('#tableId td')

您的问题标题与问题正文不同。 您可能对此解决方案感兴趣,尽管我不确定:

$('#table_id tr td:first-child')

你必须循环

尝试这个

$('#mytable tr').each(function() {
var customerId = $(this).find("td:first").html();    
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM