I came across an interesting quirk, and was wondering if anyone could help me understand it. A simple JavaScript-driven toggle button, as below, works beautifully if the display:none
of the toggled element is contained in-line. However, when I move the CSS statement to the <style>
tag in the header, or to a separate CSS file, it starts to toggle only on the second click, and from then on, it works fine, on a single-click-per-toggle basis. Here's the JS function:
<script>
function openSec(ordinal) {
var tab_name = "sec" + ordinal;
if (document.getElementById(tab_name).style.display == "none") {
document.getElementById(tab_name).style.display = "table";
} else {
document.getElementById(tab_name).style.display = "none";
}
}
</script>