Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does jQuery's css method block until the change is fully applied?

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?

like image 809
alexgolec Avatar asked Dec 20 '22 00:12

alexgolec


1 Answers

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.

like image 120
zzzzBov Avatar answered May 05 '23 04:05

zzzzBov