I am struggling with the following code. Can any one help me. How do I use a variable like “x” instead of “someimage.gif” in the following line? style.backgroundImage = url(someimage.gif)
I’m currently using a script to change the background color on any element with the class of “beadcolor1″…the following code is working!
function color1(x) {
//Populate the array with all the page tags
var allPageTags=document.getElementsByTagName(“*”);
//Cycle through the tags using a for loop
for (i=0; i<allPageTags.length; i++) {
//Pick out the tags with our class name
if (allPageTags[i].className==’beadcolor1′) {
//Manipulate this in whatever way you want
allPageTags[i].style.backgroundColor = x;
}
}
}
HOWEVER, instead of changing the background color, I want to change the background image. I have the following code but is not working. Any help?
function color1(x) {
//Populate the array with all the page tags
var allPageTags=document.getElementsByTagName(“*”);
//Cycle through the tags using a for loop
for (i=0; i<allPageTags.length; i++) {
//Pick out the tags with our class name
if (allPageTags[i].className==’beadcolor1′) {
//Manipulate this in whatever way you want
allPageTags[i].style.backgroundImage = x;
}
}
}