I have the following function:
function render(data){
nodes = data.nodes;
for(i=0; i<nodes.length; i++){
...
let originalColor = $("#"+i).css("background-color")
...
setTimeout(()=>{$("#"+i).css("background-color", originalColor)}, 1000)
}
}
Now, I have tried printing something inside this setTimeout, and it works!, which means it's being actually called, however, the css effect it not working.
Any clues?!
Notes:
- I am sure the dotted(skipped) code has no effect on the function.
- I am also sure that the DOM element is being selected correctly.
- I have tried many stackOverFlow solutions before posting this, non of them seemed to work :(
- I am sure that the "originalColor is a valid rgb() value.
Full function upon request:
function render(data){
nodes = data.nodes;
for(i=0; i<nodes.length; i++){
$("#"+i).css("background-color", ()=>{
return nodes[i]["color"]=="Blue"? "dodgerblue" : "red";
})
let originalArmies = $("#"+i).text()
$("#"+i).text(nodes[i]["armies"])
if(originalArmies != $("#"+i).text()){
let originalColor = $("#"+i).css("background-color")
$("#"+i).css("background-color", "yellow")
setTimeout(()=>{$("#"+i).css("background-color", originalColor)}, 1000)
}
}
}