Hi All,
I'm trying to get this script to work:
Code:
<script language="javascript" type="text/javascript">
function toggle(item) {
obj=document.getElementById(item);
visible=(obj.style.display!="none")
key=document.getElementById("collapse_" + item);
if (visible) {
obj.style.display="none";
key.innerHTML="[+] Expand";
}
else {
obj.style.display="block";
key.innerHTML="[-] Collapse";
}
}
</script>
Here is my current HTML:
Code:
<a id="collapse_collections" href="javascript:toggle('collections')">[+] Expand</a><br />
<div id="collections" style="display:none">
<a href="/site/interests/collections/books">Books</a><br />
<a href="/site/interests/collections/magazines">Magazines</a><br />
<a href="/site/interests/collections/movies">Movies</a><br />
<a href="/site/interests/collections/music">Music</a><br />
<a href="/site/interests/collections/video_games">Video Games</a><br />
<a href="/site/interests/collections/wristwatches">Wristwatches</a><br />
</div>
Right now, when I expand/collapse, the links are showing up as [+] Expand or [-] Collapse. However, I'd like to be able to put any text after "Expand" or "Collapse" and include it as part of the link, so that it could be like so:
[+] Expand Music
[+] Collapse Music
[+] Expand Video Games
[+] Collapse Video Games
etc. The key is probably in this part of the JS:
Code:
key.innerHTML="[+] Expand";
key.innerHTML="[-] Collapse";
However, I'm a JS n00b, and am not sure how to do this... If someone could help me, I'd really appreciate it! Thanks in advance...
|