gpt4 book ai didi

Javascript:setTimeout 中没有发生 DOM 事件

转载 作者:行者123 更新时间:2023-11-30 14:41:12 25 4
gpt4 key购买 nike

<分区>

这是我的 JS 代码

for (var i=0; i<500; i++) {
var compare = cryptoSName[i].innerHTML
if (compare == crypto) {
document.getElementById("cryptotable" + i).style.color = "#00000"
document.getElementById('price' + i).innerHTML= "$" + (tradeMsg.message.msg.price.toFixed(4));;
document.getElementById('perc' + i).innerHTML= tradeMsg.message.msg.perc + "%";
setTimeout(function() {
document.getElementById("cryptotable" + i).style.color = "#ff0000"
}, 500);
}
}

当我运行它时,它抛出一个错误,提示 cannot read property style of null

现在,如果我删除它,它会工作得很好。 我在这里做错了什么?另外,我的目标是仅更改元素的颜色几秒钟。我怎样才能做到这一点? (我正在尝试使用 setTimeout 函数)

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