18910140161

html-从jquery选择器返回一个数组每个函数-堆栈溢出

顺晟科技

2022-10-19 13:06:16

133

我有一个表,我在其中获取所有行的第1列td和第9列tds的值

$("table tr").each(function() {
  return ($(this).find("td").eq(0).text() + " " + $(this).find("td").eq(8).text())
}).join("#")

我需要得到数组形式的结果

AS

$("table tr").each(function() {
  return ($(this).find("td").eq(0).text() + " " + $(this).find("td").eq(8).text())
}).join("#")

预期结果为

$("table tr").each(function() {
  return ($(this).find("td").eq(0).text() + " " + $(this).find("td").eq(8).text())
}).join("#")

如何修改迭代以返回数组。然后,我可以使用所需的任何字符进行连接。


顺晟科技:

您可以这样做:

$("table tr").each(function() {
  return ($(this).find("td").eq(0).text() + " " + $(this).find("td").eq(8).text())
}).join("#")

不会返回所需的重定向结果,而是返回表中的所有

演示

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航