Is there a way to wait for a particular tab/panel to be displayed (display : block) before the JS is executed?
something like:
$document.getElementById( '#panel1' ).style.display = 'block' {
// Run code //
}
Is there a way to wait for a particular tab/panel to be displayed (display : block) before the JS is executed?
something like:
$document.getElementById( '#panel1' ).style.display = 'block' {
// Run code //
}
There is currently no reliable cross-browser method to listen for a change to a CSS property via JavaScript. Instead, you would need whatever script is setting display: block
to run the additional code when it's complete.
For example:
function showPanel() {
document.getElementById( '#panel1' ).style.display = 'block';
// Run code //
}
Or with jQuery:
function showPanel() {
$('#panel1').show();
// Run code //
}
As was mentioned in another comment by Jared Farrish, you could look into the MutationObserver. However, it won't work in older browsers, like IE < 11, or on some mobile devices.