Skip to content
WJunction - Webmaster Forum

Hide & Display Content With Javascript

Status
Not open for further replies.
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.

About the author

B
Active Member · Joined
97
Messages
0
Reactions
6
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom