- Jreedy88
- Jun 26, 2005
-
thirty4
|
I have this in my CSS:
code:#headers
{
display:none;
}
And I'm trying to use this JavaScript in a function later on to dynamically display something:
code:document.getElementById("headers").style.display = "";
It's a no go. I don't understand why it's not making it visible. I've done this tons of times before without defining the style in the stylesheet. Now that I've defined the style of none in the sheet, it won't reappear. Also, is there a better way to do this?
I just want the element to be invisible on page load and visible after a function is called.
|
#
¿
Jun 19, 2009 17:26
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 6, 2024 08:05
|
|
- Jreedy88
- Jun 26, 2005
-
thirty4
|
Lumpy posted:
Set the display to block.
Think "none" = invisible, "block" = visible
Yay! Worked like a charm. Thanks.
|
#
¿
Jun 19, 2009 17:48
|
|
- Jreedy88
- Jun 26, 2005
-
thirty4
|
Supervillin posted:
FYI, when you set it to "" you're telling it to set display to whatever its default is, which according to your CSS is "none"; that's why it seemed like it didn't do anything.
Often when you come across snippets that hide/show stuff they'll use display="none" to hide it and display="" to show it, because the default could be "inline", "block", etc. depending on the element.
Yeah, block formatting messed my page design anyways so I ended up just doing a display="none" on the element in javascript after the page had loaded.
Jreedy88 fucked around with this message at 16:25 on Jun 26, 2009
|
#
¿
Jun 26, 2009 15:14
|
|