Link to home
Start Free TrialLog in
Avatar of heng03
heng03

asked on

Show/Hide HTML

Hi

I want to show a button that display "Show" initially.
When click on it, the hidden html text will display & the button will show "hide".

Now when user click "hide", the shown html text will be hidden again.

Pls help.

Thanks & Rgds
Heng03

ASKER CERTIFIED SOLUTION
Avatar of boonleng
boonleng
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of heng03
heng03

ASKER

Hi

I increase point to 75.
I would like both you to share.

Thanks & Rgds
Heng03
Avatar of heng03

ASKER

Hi boonleng

how to suppress the spaces (lines) when invisible mode ?
That is, my messages contains many lines.

Thanks & Rgds
Heng03
Use "display" instead of "visibility".

if (button.value == 'show') {
  button.value = 'hide';
  element.style.display = 'block';
} else {
  element.style.display = 'none';
  button.value = 'show';
}

<div id="message" style="display: none"> Message Here</div>
Avatar of heng03

ASKER

Hi Boonleng

It do not work for style="display:none".
Why ?

Thanks & Rgds
Heng03