Friday, February 23, 2007

Change Image, Change Collor

function changeImage(id,img)
{
newImage = "url("+img+")";
document.getElementById(id).style.backgroundImage = newImage;
}

function changeColor(id,color)
{
document..getElementById(id).style.backgroundImage = color;
}

2 JavaScript functions that modify the color or the image of an ID. You just need to set the ID and the path of the file or the color (Depending on the function). I guess the name of each function gives you the biggest hint .

No comments: