So why does this work? The setTimeout function adds the next round of operations on the end of the call stack. This gives the jQuery DOM operation time to run, meaning: the UI has time to update. Unfortunately, this is just one of those annoying little things that can happen when working with the browser, and it’s a handy solution to keep around.