I've got some computation that I want to execute after a CSS change is applied using jQuery's css
function. Does this method wait until the CSS change is completely applied, complete with the element being repainted?
Modifying styles with JavaScript is a synchronous behavior. Updating classes, IDs, and inline styles of elements will immediately take effect on the element, and you can safely grab the new dimensions or styles of that element.
With that said, there are a few niche bugs in various browsers where repainting won't happen unless very specific style changes are made. Again, the recalculation of layout happens synchronously, but you may need to do additional work to force the repaint to happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With