I used this function on my latest website, found it came in handy and looked real nice;
Put this into any html page, the put this code for the bit that's to be toggled;
<p id="pname" style="display:none;">This is my shitty text lolz</p>
Now there's the paragraph, you need a link to toggle it visible, or not.
<a href="Javascript:toggle('pname');">Link Text</a>
This is REALLY effective when you use CSS with it, and it looks really pro :P
<script type="text/javascript">
function toggle(obj) {
var toggle = document.getElementById(obj);
if (toggle.style.display != "none") {
toggle.style.display = "none";
}
else {
toggle.style.display = "inline";
}
}
</script>
It is possible, what i'd do (bearing in mind that i am not very good at javascript) is while loop to close them all then open a single one. for example
function collapse(open) {
for (x=1;x<=[NUMBER_OF_PARAGRAPHS];x++) {
document.getElementById("objectname" + x).style.display = "none";
}
document.getElementById("objectname" + open).style.display = "inline";
}
Hope that helps!
No, i found it only worked with
not sure about and as you say, doesnt work with
I\'ll check it out and get back to you, but i am a JS idiot lol.
You could put the link text within a
so for instance;
<p id=\"paralink\" style=\"display:inline;\"><a href=\"Javascript: toggle(\'para\'); toggle(\'paralink\');\">Toggle</a></p>
<p id=\"para\" style=\"display:none;\">This is my shitty text lolz</p>
that should work.