how to do this, show hide example?

S

scripts.contact

Hi,
Can someone explain how to do the "Hide Example" "Show Example" thats
on this page:http://msdn.microsoft.com/library/default.asp?url=/workshop/author/pe...


it is CSS style attribute display. Example-

<body style="font:.8em arial">
<script>
function showHide(E){
var Elm=document.getElementById(E)||{style:{}}
Elm.style.display=Elm.style.display=='none'?'':'none'
}
</script>
<b onclick="showHide('example')" style="text-
decoration:underline">Show Example</b><br>
<span id=example >
some content ....
</span>
</body>
 
S

soni2926

hi,
if i try the below, using your example:
<body style="font:.8em arial">
<script>
function showHide(E){
var Elm=document.getElementById(E)||{style:{}}
Elm.style.display=Elm.style.display=='none'?'':'none'


}


</script>
<b onclick="showHide('example')" style="text-
decoration:underline">Show Example</b><br>
<span id=example >
some content ....
</span>
<br>hello i'm below the span.....<br>
so am i
</body>

it hides, but when it does it leaves a gap above "hello i'm below..."
while that microsoft page, it didn't leave a gap when hidden. anyway
to avoid that gap?
 
S

scripts.contact

hi,
if i try the below, using your example: ....
it hides, but when it does it leaves a gap above "hello i'm below..."
while that microsoft page, it didn't leave a gap when hidden. anyway
to avoid that gap?

yes.

this is the html content-

<b >Show Example</b>
<br>
<span>some content ....</span>
<br>
hello i'm below the span.....
<br>
so am i

after hiding the span element :

<b >Show Example</b>
<br>
<br>
hello i'm below the span.....
<br>
so am i
----------

as you can see, now there are 2 line breaks.
To avoid this, put one <br> inside the span element :

<b>Show Example</b><br>
<span id=example >
some content ....
<br>
</span>
hello i'm below the span.....<br>
so am i


: )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top