Do this with JS.
Say you have the following:
Code:
<div id="mydiv">
blah blah blah on top of the background
</div>
Where you have a background image on the div defined by CSS.
For example:
Code:
#mydiv {
background-image: url(thisimage.jpg);
}
to change the background image of that div you can use the following js script:
Code:
document.getElementById("mydiv").style.backgroundImage = "url(anotherimage.jpg)"
To hide/show a DIV you can use the following code:
Code:
function showHide(ref){
if (document.getElementById(ref).style.display == ""){
show = "none";
}
else {
show = "";
}
document.getElementById(ref).style.display = show;
}
Where 'ref' is the ID of the element passed in the function call. For example:
Code:
<a href="#" onclick="showHide('mydiv')">Show/Hide</a>
Many javascript libraries, like prototype.js , have a built in 'toggle' function that automatically does the above with a simple piece of code like:
Code:
function showHide(ref){
Element.toggle("ref");
}
Which is a lot less code but you have to load the whole JS library in as well so... it's only useful if you're using a lot of JS.