Web Hosting Talk







View Full Version : please help me with the change title and show/hide text java-script


hello20109876
05-07-2006, 06:47 AM
code is a little bit long (tens of lines), so I upload it to somewhere.

please click the link
http://www.syncedit.com/zzz/single.html
to see my question.

please ask if my question is not clear.

thanks

.

PlanetWebHost
05-07-2006, 08:53 AM
here ya go..


<script type="text/javascript"><!--
function show(id, cntl)
{
el = document.getElementById(id);
cntl = document.getElementById(cntl);
if (el.style.display == 'none')
{
el.style.display = '';
cntl.innerHTML = 'Less';
} else {
el.style.display = 'none';
cntl.innerHTML = 'More';
}
}
--></script>



<a href="#" onClick="show('text', 'link');" id="link">More</a>
<div id="text" style="display:none;">This is he hidden text</div>

hello20109876
05-07-2006, 11:56 AM
I can not believe about that!
You are a script genius, aren't you?

I used 3 days in 3 forums for getting code in my post - but you made it so short and nice!


Really want to say Thanks!

Is it possible to add background image for text More?

.

PlanetWebHost
05-07-2006, 12:03 PM
lol, np.


and yes, a <div> tag creates a line feed, <span> should work just as well if you don't want it to create a new line.

hello20109876
05-07-2006, 12:17 PM
thanks,
i fixed line-break by changing div to span.

do you think if i can add background image for More?

cheers

.