javascript - 第二个 While 循环返回一个实例
问题描述
下面的代码只是我整个代码的一个片段,我遇到的问题是第一个 while 循环返回所有实例,但第二个 while 循环只返回一个实例。我试过把它们放在不同的功能中,但这没有帮助,有人可以帮忙吗?
function refreshCurveData() {
selectedDate = document.querySelectorAll(".buyclass .column-date.sorting_1")[1].textContent;
buyPriceTable = document.querySelectorAll(".buyclass td.column-price");
buyVolTable = document.querySelectorAll(".buyclass td.column-volume");
sellPriceTable = document.querySelectorAll(".sellclass td.column-price");
sellVolTable = document.querySelectorAll(".sellclass td.column-volume");
let i = 0;
do {
var buyPriceData1 = buyPriceTable[i].textContent;
var buyVolData1 = buyVolTable[i].textContent;
buyPriceData[i] = {
x: parseFloat(buyPriceData1.replace(/\,/g, '')),
y: parseFloat(buyVolData1.replace(/\,/g, ''))
};
i++;
}
while (document.querySelectorAll(".buyclass .column-date.sorting_1")[i].textContent === selectedDate);
let j = 0;
do {
var sellPriceData1 = sellPriceTable[j].textContent;
var sellVolData1 = sellVolTable[j].textContent;
sellPriceData[j] = {
x: parseFloat(sellPriceData1.replace(/\,/g, '')),
y: parseFloat(sellVolData1.replace(/\,/g, ''))
};
j++;
}
while (document.querySelectorAll(".sellclass .column-date.sorting_1")[j].textContent === selectedDate);
}
setInterval(() => {
refreshCurveData();
scatterChart.update();
}, 2500);
解决方案
推荐阅读
- visual-studio-code - Visual Studio Code 的 Marklogic XQY 调试器
- javascript - 如何使用animejs制作动画?
- json - Ansible将月份转换为整数
- regex - Splunk:如何在一个查询中使用多个正则表达式?
- angular - Angular - 检测存储的组件是否已重新连接或分离
- python - 使用 Pandas 整理 Excel 工作表
- javascript - 为什么每次击键后react form的onSubmit都会触发,如何使用enter按钮提交表单?
- r - 如何解决 ggalluvial/ggplot2 中无法识别数据的问题?
- r - 如何在 R 中迭代的函数中包含停止规则?
- c# - Xamarin - 如何将来自 Rest API 的数据绑定到 StackLayout 而不是 ListView