How to force an Element to repaint/rerender in js? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to force an Element to repaint/rerender in js?

I have been working on an element for rotating through content. The classes are assigned correctly, but the element doesn‘t get repainted. Is there a way to force the repainting? My Code: https://code.sololearn.com/WWoy4s6jtlD1/?ref=app

19th Dec 2019, 8:03 AM
e90d0e_red
e90d0e_red - avatar
2 Answers
+ 1
Found the error. I used Integers as Objectkeys and tried to test with index === 1. JavaScript seems to convert them to strings though. Meaning that I should have tested like this: index === "1" This resulted in a failure while setting the new css class.
19th Dec 2019, 12:16 PM
e90d0e_red
e90d0e_red - avatar
0
I didn't take an in-depth look at your code yet but generally speaking you would simply use JavaScript to change the CSS attribute.
19th Dec 2019, 9:52 AM
grdr