Every once in a while, Chrome will render perfectly valid HTML/CSS incorrectly or not at all. Digging in through the DOM inspector is often enough to get it to realize the
An approach that worked for me on IE (I couldn't use the display technique because there was an input that must not loose focus)
It works if you have 0 margin (changing the padding works as well)
if(div.style.marginLeft == '0px'){
div.style.marginLeft = '';
div.style.marginRight = '0px';
} else {
div.style.marginLeft = '0px';
div.style.marginRight = '';
}
It helped me
domNodeToRerender.style.opacity = 0.99;
setTimeout(() => { domNodeToRerender.style.opacity = '' }, 0);
Hiding an element and then showing it again within a setTimeout of 0 will force a redraw.
$('#page').hide();
setTimeout(function() {
$('#page').show();
}, 0);
I wanted to return all the states to the previous state (without reloading) including the elements added by jquery. The above implementation not gonna works. and I did as follows.
// Set initial HTML description
var defaultHTML;
function DefaultSave() {
defaultHTML = document.body.innerHTML;
}
// Restore HTML description to initial state
function HTMLRestore() {
document.body.innerHTML = defaultHTML;
}
DefaultSave()
<input type="button" value="Restore" onclick="HTMLRestore()">
None of the above answers worked for me. I did notice that resizing my window did cause a redraw. So this did it for me:
$(window).trigger('resize');
Below css works for me on IE 11 and Edge, no JS needed.
scaleY(1)
does the trick here. Seems the simplest solution.
.box {
max-height: 360px;
transition: all 0.3s ease-out;
transform: scaleY(1);
}
.box.collapse {
max-height: 0;
}