How do you toggle the visibility of an html element in Javascript?
<p>I was wondering if anyone could figure out why my function won't work properly. What I am trying to achieve is when a button is clicked it displays text and when it is clicked again it hides it and so on.</p>

<pre><code>function hideshow (){
    var showhide=document.getElementById('text');
    if(showhide.style.display="none")
    {
        showhide.style.display="block";
    }
    else{
        showhide.style.display="none";
    }
}
</code></pre>

<p>So far I got it to display my text when I click it once, but once I click it again it has no effect on the text.</p>
