Hello, i have almost no experience with Javascript but i had a problem which required me to use it.
the problem is a user should be able to hide/display a certain div which is located on the index and viewable from the entire site.
I found a very helpful code online but it still has one problem, as soon as a internal link or button is clicked it resets the hidden div to it’s default status (for example, a user hides the div, then clicks a other button and then the div just reapers because display is it’s current default status).
The Code:
<script type=”text/javascript”>
function toggle_visibility(id)
{
var e = document.getElementById(id);
e.style.display = ((e.style.display!=’none’) ? ‘none’ : ‘block’);
}
</script>
<span onclick=”toggle_visibility(‘divname’);”> hide/display </span>
<div id=”divname” >
Div Content
</div>
I hope somebody has the time & experience to help me.