I'm having an issue with a link on my webpage that is supposed to show or hide a
<div id="po" style="display:none;">some html</div>
element. The first time I click the link, the div displays properly. However, after that initial click, the link stops working and I can't figure out why. I even tried setting the <div style="display:block;">
and clicking the link caused the div to hide, but then it wouldn't show again. This behavior is puzzling to me as I have the exact same setup elsewhere on the page and it toggles correctly.
function po() {
po = document.getElementById('po').style.display;
if (po == "none") {
document.getElementById('po').style.display = 'block';
document.getElementById('po_Menu').src = "images/menu_dash.jpg";
} else {
document.getElementById('po').style.display = 'none';
document.getElementById('po_Menu').src = "images/menu_plus.jpg";
}
}
<img id="po_Menu" src="https://via.placeholder.com/50"> <a href="po()">show/hide</a>