Re: Simple Expand/Contract Help :)
Quote:
Originally Posted by max99
Im looking for a simple expand/contract script like used on Keiths Internet Marketing Blogs UK site, but I dont want it using feeds I want it just with extra info in it. Like that used on youtube in video description, where you can click "more info" or another word/button and the box expands and shows more info and then can be contracted.
If anyone could help would really appreciate it  been trying/googling and messing around with 1 script i found for ages but with no success
|
The very simplest way would be
Code:
<script type="text/javascript">
function showIt(){
if(!document.getElementById)return;
document.getElementById('stuff').style.display=(document.getElementById('stuff').style.display=='none')?'':'none';
}
</script>
<a href="javascript:;" onclick="showIt(); return false;">Show Info</a>
<div id="stuff" style="display:none;">
<p>some stuff here....</p>
</div>
You might want to enhance this
1/ For accessibility. Anyone with js off would never be able to read the text. A better way would be to have the text visible then hide it with js onload.
2/ To look better. You could either change the link text from Show Info to Hide Info when the link is clicked and/or use 2 background images, say little arrows on the link and toggle them onclick.
Hopefully this will get you started
Cheers,
Jon
|