For a hobby site, I found this script and I'd like it to work the other way
around. The content has to show and the visitor has to click to hide it.
Could someone help me please? I'm a total Java-newbie...
TIA
Jaap
Here's the code:
in <head>tag
<script type="text/javascript">
<!--
var storedDiv = null;
function getDiv(oID) {
if(document.getElementById) {
return document.getElementById(oID);
} else if( document.all ) {
return document.all[oID];
} else { return null; }
}
window.onload = function () {
for( var i = 0, y; y = getDiv('ans'+i); i++ ) {
y.style.display = 'none';
}
};
function toggleInfo(oID) {
var oDiv = getDiv(oID); if( !oDiv ) { return; }
oDiv.style.display = (oDiv.style.display=='none') ? 'block' : 'none';
if( storedDiv && storedDiv != oDiv ) { storedDiv.style.display = 'none';
} storedDiv = oDiv;
}
//--></script>
in <body>tag
<span style="cursor:hand; cursor:pointer" onclick="toggleInfo('ans0');">
Hide/show content
</span><br><br>
<div id="ans0">
content
</div>