Forum Moderators: open

Message Too Old, No Replies

JavaScript show/hide

How to?

         

Shingetsu

4:10 am on Jan 19, 2011 (gmt 0)

10+ Year Member



Hey all, I'm mostly a php coder, but I tend to use js and trying to learn Ajax.. How exactly does a js show/hide function work?
As an example just post a function with the code initial XD.
I'm not sure, but is it also possible to
GetElementById('ID').elem.style.opacity = x

X being defined in
Function(x)

? Or is that error red code?

daveVk

5:44 am on Jan 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



toggle style.display between 'none' and '' if by hide you mean take up no space.

Shingetsu

10:53 am on Jan 19, 2011 (gmt 0)

10+ Year Member



By hide I mean disappear, but have the other elements go up to take it's place.
Kind of how a rollover menu works.

daveVk

12:28 pm on Jan 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good then toggling style.display is the way to go. Changing visibility or opacity (not as well supported) leaves hole where content was.

Shingetsu

12:50 pm on Jan 19, 2011 (gmt 0)

10+ Year Member



Thanks!
-solved-