So this my JS code
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);
}
}
when I run this, it throws an error saying that cannot read property style of null
Now, If I remove this, It works perfectly fine. What am I doing wrong here? Also, My goal here is to change the color of an element just for few seconds. How can I achieve that? (I was trying to do with setTimeout function)