简体   繁体   中英

jQuery Get All First Cells Of Table

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

try first-child

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

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

$('#tableId td')

Your question title is different from your question body. You may be interested in this solution, although I can't be sure:

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

You have to loop it

Try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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