Javascript:循环遍历变化数组中的元素

问题描述 投票:0回答:1

我有一个网页,其中包含我想要重新组织的表单。 所有字段都在一个

javascript loops
1个回答
0
投票

如果你改变它,你总是可以在循环之前浅复制一个可迭代对象:

[...$('table#tableForm')[0].firstChild.childNodes].forEach((c) => {
  content = $(c).find('td')[0].innerText
  if (toMove[content]) {
    $('#'+toMove[content]).appendTo(c)  // <= This change *.childNodes, next iteration will miss the next element
  }
});
© www.soinside.com 2019 - 2024. All rights reserved.