gpt4 book ai didi

jquery - 将所有表 td 值放入数组中

转载 作者:行者123 更新时间:2023-12-03 22:55:27 25 4
gpt4 key购买 nike

我需要将所有 td 值放入字符串数组中。以下是我的代码

var tr = "#tblPurchaseOrders tr.PO1";

$(tr).each(function(index, tr) {
var lines = $(tr + " td").map(function(ind, td) {
var ret = {};
ret[ind] = $(td).text();
return ret;
}).get();

// I need to some more thing here

// I need to store all the td values in to lines variable.. This is not working for me.
// Am I missing some thing?

});

谢谢。

最佳答案

尝试这样:

$('#tblPurchaseOrders tr.PO1').each(function(index, tr) {
var lines = $('td', tr).map(function(index, td) {
return $(td).text();
});
// Here lines will contain an array of all td values for the current row:
// like ['value 1', 'value 2', 'value 3']

});

关于jquery - 将所有表 td 值放入数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5991011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com