JavaScript链接图片不起作用

时间:2014-03-30 16:56:08

标签: javascript

我无法将本地照片(位于同一目录中)与javascript相关联。当我尝试在浏览器中运行它时,我只得到按钮。请帮忙!!!!

var images = new Array(8);
images[0] = "photo1.jpg";
images[1] = "url('screen2.jpg')";
images[2] = "url('screen3.jpg')";
images[3] = "url('screen4.jpg')";
images[4] = "url('screen5.jpg')";
images[5] = "url('screen6.jpg')";
images[6] = "url('screen7.jpg')";
images[7] = "url('screen8.jpg')";
var i = 0;

function slideShowForward(){
    if(i == 7){
        i = 0;
        document.getElementById("images").style.backgroundImage = images[i];
    }
    else{
        i++;
        document.getElementById("images").style.backgroundImage = images[i];
    }
}
function slideShowBack(){
    if(i == 0){
        i=7;
        document.getElementById("images").style.backgroundImage = images[i];
    }
    else{
        i--;
        document.getElementById("images").style.backgroundImage = images[i];
    }
}

0 个答案:

没有答案