Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
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.

Adbot
ADBOT LOVES YOU

Jreedy88
Jun 26, 2005
thirty4

Lumpy posted:

Set the display to block.

Think "none" = invisible, "block" = visible

Yay! Worked like a charm. Thanks.

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply