PDA

View Full Version : hiding divs



Bennelliott
04-28-2007, 05:12 PM
Hey, i got a pretty simple script which hides divs when you click a link, but I wanted to make the divs be hidden as default.
Here's the simple bit of code:

function hideshow(which){
if (!document.getElementById)
return
if (which.style.display=="block")
which.style.display="none"
else
which.style.display="block"
}

I've tried changing the 'else' line:
which.style.display="block" ==> to ==> which.style.display="none" but that has the undesirable effect of hiding it and not allowing it to be shown again.

Any ideas?
Tyvm in advance :p

Bennelliott
04-28-2007, 05:15 PM
never mind, in the div that i wanted to hide by default i just put style="display:none" in the tag.
I am silly lol

thetestingsite
04-28-2007, 05:17 PM
Simply use this in the div:



<div style="display: none;">


That will make the div hidden when the page loads.
Hope this helps.

//EDIT: Sorry, cross posted. Glad you figured it out though.

Bennelliott
04-28-2007, 05:27 PM
Yer, i usually work it out for myself JUST AFTER i post lol.