PDA

View Full Version : How can I create a 'spoiler' box?


Oeoza
06-30-2011, 04:26 AM
An assortment of forums have the 'Spoiler' system implemented and I was wondering if it would be possible to create something similar in Dreamweaver? My best guess is that it will use Javascript, but how would I go about creating this? I would like it so there is a button saying 'click' or 'spoiler', which when you press it will expand a section below it, revealing the information which is being contained within.

Thank you.

edbr
06-30-2011, 05:13 AM
yes javascript ,this will work
<script type="text/javascript">
function toggle(element) {
if (document.getElementById(element).style.display == "none") {
document.getElementById(element).style.display = "";
} else {
document.getElementById(element).style.display = "none";
}
}
</script>

and call it
<a href="javascript:toggle('hidden')"><span class="style1"><strong>Spoiler</strong></span></a>
<div id="hidden" style="display:none;">
Your content

</div>

Oeoza
07-01-2011, 07:27 AM
yes javascript ,this will work
<script type="text/javascript">
function toggle(element) {
if (document.getElementById(element).style.display == "none") {
document.getElementById(element).style.display = "";
} else {
document.getElementById(element).style.display = "none";
}
}
</script>

and call it
<a href="javascript:toggle('hidden')"><span class="style1"><strong>Spoiler</strong></span></a>
<div id="hidden" style="display:none;">
Your content

</div>



Thanks a lot mate; it worked. Appreciate it ^^