Currently in the final stages of developing an iPhone web app, I have encountered a small issue that needs to be resolved.
I have successfully hidden one layer and displayed another with a button click. However, what I am aiming for is to toggle between showing the initially hidden layer and hiding the currently displayed layer when the button is clicked again. In essence, reverting back to the original state with each click.
The current code snippet being used is as follows:
<script type="text/javascript">
function toggle_layout(d)
{
var onediv = document.getElementById(d);
var divs=['Posts','Posts2'];
for (var i=0;i<divs.length;i++)
{
if (onediv != document.getElementById(divs[i]))
{
document.getElementById(divs[i]).style.display='none';
}
}
onediv.style.display = 'block';
}
</script>
While this script effectively hides the "Posts" div and displays the "Posts2" div, it does not reverse the effect upon clicking again.
If interested in exploring my website, you can visit . Please view it on a mobile device to see the issue at hand.