Hide & Display Content With Javascript

Status
Not open for further replies.

blow

Active Member
97
2010
0
85
I want to hide something on my website & show it with javascript. Like this:
''Click Here For Options'' Then when you click the link the options tab opens up...

I found this code it works, but the content IS SHOWN by default, then when you click the link it hides it:

Code:
 <a href="javascript:hideshow(document.getElementById('adiv'))">Click Here For Options</a>

<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}
</script>

<div id="adiv" style="font:24px bold; display: block">my code to display the options</div>

Does anyone know how i can make this the other way round & hide the content by default then display it when i click the link?
 
2 comments
This?

<a href="javascript:hideshow(document.getElementById('adiv'))">Click Here For Options</a>

<script type="text/javascript">
function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="none")
which.style.display="block"
else
which.style.display="none"
}
</script>


<div id="adiv" style="font:24px bold; display: none;">my code to display the options</div>
 
It's the same m8...
Do i need to hide the content with css, so it'll be hidden when your first view the page. Then use that code to show the content when i click the Click Here For Options link?
 
Status
Not open for further replies.
Back
Top