JSFiddle - React, Tailwind, and code Playground
HTML
<div id='panel1'>
text to hidden
</div>
<button onclick="testFunction()">Hide</button>
JavaScript
function simulateComplexOperation(sleepDuration) {
var now = new Date().getTime();
while (new Date().getTime() < now + sleepDuration) { /* do nothing */ }}
function testFunction() {
document.getElementById('panel1').style.display = 'none';
console.log('before');
simulateComplexOperation(2000);
console.log('after');
}