Default to all hidden
//----- HIDE ALL OPTIONAL WIDGETS AND SECTIONS OF THE PAGE INITIALLY -----
$HtmlOutput .= <<<_END
<style>
#MyButton1,
#MyButton2 {
visibility: hidden;
}
#MySection1,
#MySection2 {
display: none;
}
</style>
_END;
To then display a section
$HtmlOutput .= <<<_END
<script>
document.addEventListener("DOMContentLoaded", function(event)
{
document.getElementById('MySection1').style.display = 'flex';
});
</script>
_END;
Display it if it exists
<script>
document.addEventListener("DOMContentLoaded", function(event)
{
const el = document.getElementById('MySection1');
if (el)
el.style.display = 'flex';
});
</script>
