Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery获取表的所有第一个单元格_Javascript_Jquery - Fatal编程技术网

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

Javascript jQuery获取表的所有第一个单元格,javascript,jquery,Javascript,Jquery,我需要获取某个表中所有行的所有tds(单元格),是否有一种优雅的方法来实现这一点,或者我是否需要自己循环收集?此代码将返回表中id=tableId的所有tds $('#tableId td') 尝试第一个孩子 $('table tr td:first-child') or $("table tr td:first") or $("table tr td").first() 您的问题标题与问题正文不同。您可能对该解决方案感兴趣,但我不能确定: $('#table_id tr td:f

我需要获取某个表中所有行的所有tds(单元格),是否有一种优雅的方法来实现这一点,或者我是否需要自己循环收集?

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

$('#tableId td')

尝试
第一个孩子

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

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

$('#table_id tr td:first-child')
你必须循环它

试试这个

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