JavaScript code snippet to force a DOM element redraw/repaint. A bit hacky but useful as a last resort.

var element = document.getElementById('id');
var n = document.createTextNode(' ');
var disp =;  // don't worry about previous display style

element.appendChild(n); = 'none';

setTimeout(function(){ = disp;
},20); // you can play with this timeout to make it as short as possible

Using Transit.js

If your using a transition plugin like transit.js this also works:

    .transition({ x: '-500px', easing: 'snap', duration:'0' })
    .transition({ x: '0', easing: 'snap', duration:'0' })


#element {
     position: absolute;
     right: '-500px';
     z-index: -1;
Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.

Free Guide:

How to Choose the Right Charting Library for Your Application

How do you make sure that the charting library you choose has everything you need? Sign up to receive this detailed guide from FusionCharts, which explores all the factors you need to consider before making the decision.

Learn JavaScript for free!
Free course: Introduction to JavaScript

Yours when you take up a free 14-day SitePoint Premium trial.