PDA

View Full Version : Disapearing/apearing <div>


pinkotoad
08-14-2002, 11:25 PM
What I need to do is relatively simple. I was fiddling around with it last night, and got to to work almost the way I wanted to, but then the power went out, and can't remember for the life of me what I was doing... :confused:

I have a <span> and a <div>. The <div> starts out as invisible ("display:none;" so that it won't effect the rest of the page while it isnt visible). What I want is when the <span> is clicked, the <div> to become visible.

Thanks for any help.

x_goose_x
08-15-2002, 12:41 AM
<script>

function show_hide(what) {
d = document.getElementById(what).style.display;
if (d=="") {
document.getElementById(what).style.display = "none";
}else{
document.getElementById(what).style.display = "";
}
}

</script>

<div id="whatever" style="display: none;">Don't tell anyone but this is hidden.</div>

<a href="javascript: show_hide('whatever');">Click here</a>

<br><br>

<div onclick="show_hide('whatever');">Or here.</div>

beetle
08-15-2002, 04:43 AM
<script>
function toggleDisp(objID)
{
var o = document.getElementById(objID);
o.style.display = (o.currentStyle.display == 'none') ? 'block' : 'none';
}
</script>

<div id="myDiv" style="display:none;">content</div>
<span onClick="toggleDisp('myDiv')">Click here to toggle</span>

t3cat5
08-18-2002, 02:43 PM
there are 2 version a basic and advanced version with tabs on my site enjoy!! I hope its what you were after and if so please vote. note there are no popups or banner on this site so a vote would be nice ya know....

get the code here: http://www.4gigs.com/~t3cat5/