Howto: Force a browser redraw/repaint
The one which works almost everytime is reassigning the class name:
el.className = el.className
But the above fix doesn’t work for absolute positioned elements and in some other cases. I came up with the following solution.
By changing the padding for a very short moment (1ms) and changing it back afterwards to its original value a browser redraw gets triggered.
For convenience sake I wrote a jQuery plugin which is available at http://plugins.jquery.com/project/force_redraw.
$('#myelement').forceRedraw(); //same as el.className = el.className $('#myelement').forceRedraw(true); //this will use the padding method
That’s it! I really hope it will save you lots of time!