I'm trying to make a photo gallery where the background image of a div element changes to the image whose thumbnail you mouseover (can't use jquery for this) Here's a screenshot of my js code: screenshot here, I've also pasted it below if you'd rather see it in the text box:
<javascript>
function displayImage(event){
event = event || window.event;
var targetElement = event.target || event.srcElement;
if(targetElement.tagName == "IMG")
{
document.getElementById("viewer").style.backgroundImage = targetElement.getAttribute("src");
}
}
</javascript>
where the "viewer" id is that of the div element I want my photos to appear, and the onmouseover=displayImage is called in the div container tag of my image tags.
Thanks for any help!
Aucun commentaire:
Enregistrer un commentaire