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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi boonleng
how to suppress the spaces (lines) when invisible mode ?
That is, my messages contains many lines.
Thanks & Rgds
Heng03
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>
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>
ASKER
Hi Boonleng
It do not work for style="display:none".
Why ?
Thanks & Rgds
Heng03
It do not work for style="display:none".
Why ?
Thanks & Rgds
Heng03
ASKER
I increase point to 75.
I would like both you to share.
Thanks & Rgds
Heng03