Could someone give me a quick clue as to why the following, very simple, JS isn't working properly, please?
<script>
function toggleResponseArea() {
if (document.getElementById("commentResponse").style.display = 'none') {
document.getElementById("commentResponse").style.display = 'block';
} else if (document.getElementById("commentResponse").style.display = 'block') {
document.getElementById("commentResponse").style.display = 'none';
}
return false;
}
</script>
The text area is initially set to display: none; in the stylesheet. I've used an onclick attribute for the 'reply' element in the HTML.
And to be clear, when the page is loaded (display: none;) and the reply 'button' is clicked it does change the textarea to display: block; that's not the problem. The issue is when it's clicked again it doesn't change it back from display: block; to display: none;
Thanks for the help.