You can do that without using images. Try these modifications to the original demo:
Below the line that says:
Code:
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)
add this variable:
Code:
var nbs=(document.getElementById&&!document.all)? ' ' : ''
Replace 'function contractcontent' with this version:
Code:
function contractcontent(omit,omitspan){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
var spans=document.getElementsByTagName('span')
for (i = 0; i < spans.length; i++){
if (spans[i].id.indexOf('sp')!==-1&&spans[i].id!==omitspan)
spans[i].innerHTML='+'
}
}
Replace 'function expandcontent' with this one:
Code:
function expandcontent(cid,sid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid,sid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
document.getElementById(sid).innerHTML=(document.getElementById(sid).innerHTML==nbs+'-')? '+' : nbs+'-'
}
}
Replace 'function revivecontent' with:
Code:
function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++){
document.getElementById(selectedComponents[i]).style.display="block"
var spansId='sp'+document.getElementById(selectedComponents[i]).id.substr(2)
document.getElementById(spansId).innerHTML=nbs+'-'
}
}
Finally, add this to your html markup:
HTML Code:
<span id="sp1" style="font-family:'arial black';display:inline-table;width:1em;text-align:center">+</span>
Make sure that the id="sp1" uses the same number as the id="sc#" that follows it. And be sure to include the new span id in the call for expandcontent(). Ex:
HTML Code:
<h3 onClick="expandcontent('sc1','sp1')" style="cursor:hand; cursor:pointer"><span id="sp1" style="font-family:'arial black';display:inline-table;width:1em;text-align:center">+</span> What is JavaScript?</h3>
<div id="sc1" class="switchcontent">
JavaScript is a scripting language originally developed by Netscape to add interactivity and power to web documents. It is purely client side, and runs completely on the client's browser and computer.
</div>
Bookmarks