单击函数javascript和zindex时出错

单击函数javascript和zindex时出错,javascript,html,Javascript,Html,我想知道为什么我的代码为这个网站inst工作。我定义了所有必要的功能(Functions和css),但是我仍然会遇到一些错误,例如“clicked is not defined”(单击未定义),尽管脚本中有。它应该使用javascript将单击的图像带到前面。代码只是改变了zindex,将它带到了最前面 为什么这不起作用 身体 { 背景图像:url(“http://logar.gitastudent.online/images/background.png"); } #img1{ 位置:绝对

我想知道为什么我的代码为这个网站inst工作。我定义了所有必要的功能(Functions和css),但是我仍然会遇到一些错误,例如“clicked is not defined”(单击未定义),尽管脚本中有。它应该使用javascript将单击的图像带到前面。代码只是改变了zindex,将它带到了最前面

为什么这不起作用


身体
{
背景图像:url(“http://logar.gitastudent.online/images/background.png");
}
#img1{
位置:绝对位置;
左:0px;
顶部:0px;
z指数:1;
}
#img2{
位置:绝对位置;
左:10px;
顶部:10px;
z指数:1;
}
#img3{
位置:绝对位置;
左:20px;
顶部:20px;
z指数:1;
}
#img4{
位置:绝对位置;
左:30px;
顶部:30px;
z指数:1;
}
#img5{
位置:绝对位置;
左:40px;
顶部:40px;
z指数:1;
}
#img6{
位置:绝对位置;
左:50px;
顶部:50px;
z指数:1;
}
#img7{
位置:绝对位置;
左:60px;
顶部:60px;
z指数:1;
}
#img8{
位置:绝对位置;
左:70像素;
顶部:70像素;
z指数:1;
}
#img9{
位置:绝对位置;
左:80px;
顶部:80px;
z指数:1;
}
#img10{
位置:绝对位置;
左:90px;
顶部:90px;
z指数:1;
}
#img11{
位置:绝对位置;
左:100px;
顶部:100px;
z指数:1;
}
#img12{
位置:绝对位置;
左:110像素;
顶部:110px;
z指数:1;
}
#img13{
位置:绝对位置;
左:120px;
顶部:120px;
z指数:1;
}
#img14{
位置:绝对位置;
左:130像素;
顶部:130像素;
z指数:1;
}
#img15{
位置:绝对位置;
左:140像素;
顶部:140px;
z指数:1;
}
变量=函数(id){
document.getElementById(“img1”).style.zIndex=“1”;
document.getElementById(“img2”).style.zIndex=“1”;
document.getElementById(“img3”).style.zIndex=“1”;
document.getElementById(“img4”).style.zIndex=“1”;
document.getElementById(“img5”).style.zIndex=“1”;
document.getElementById(“img6”).style.zIndex=“1”;
document.getElementById(“img7”).style.zIndex=“1”;
document.getElementById(“img8”).style.zIndex=“1”;
document.getElementById(“img9”).style.zIndex=“1”;
document.getElementById(“img10”).style.zIndex=“1”;
document.getElementById(“img11”).style.zIndex=“1”;
document.getElementById(“img12”).style.zIndex=“1”;
document.getElementById(“img13”).style.zIndex=“1”;
document.getElementById(“img14”).style.zIndex=“1”;
document.getElementById(“img15”).style.zIndex=“1”;
document.getElementById(id).style.zIndex=“2”;
}

您把脚本放错地方了。并更改
document.getElementById(id).style.zIndex=“2”
id.style.zIndex=“2”

单击的函数(id){
document.getElementById(“img1”).style.zIndex=“1”;
document.getElementById(“img2”).style.zIndex=“1”;
document.getElementById(“img3”).style.zIndex=“1”;
document.getElementById(“img4”).style.zIndex=“1”;
document.getElementById(“img5”).style.zIndex=“1”;
document.getElementById(“img6”).style.zIndex=“1”;
document.getElementById(“img7”).style.zIndex=“1”;
document.getElementById(“img8”).style.zIndex=“1”;
document.getElementById(“img9”).style.zIndex=“1”;
document.getElementById(“img10”).style.zIndex=“1”;
document.getElementById(“img11”).style.zIndex=“1”;
document.getElementById(“img12”).style.zIndex=“1”;
document.getElementById(“img13”).style.zIndex=“1”;
document.getElementById(“img14”).style.zIndex=“1”;
document.getElementById(“img15”).style.zIndex=“1”;
id.style.zIndex=“2”;
}
正文
{
背景图像:url(“http://logar.gitastudent.online/images/background.png");
}
#img1{
位置:绝对位置;
左:0px;
顶部:0px;
z指数:1;
}
#img2{
位置:绝对位置;
左:10px;
顶部:10px;
z指数:1;
}
#img3{
位置:绝对位置;
左:20px;
顶部:20px;
z指数:1;
}
#img4{
位置:绝对位置;
左:30px;
顶部:30px;
z指数:1;
}
#img5{
位置:绝对位置;
左:40px;
顶部:40px;
z指数:1;
}
#img6{
位置:绝对位置;
左:50px;
顶部:50px;
z指数:1;
}
#img7{
位置:绝对位置;
左:60px;
顶部:60px;
z指数:1;
}
#img8{
位置:绝对位置;
左:70像素;
顶部:70像素;
z指数:1;
}
#img9{
位置:绝对位置;
左:80px;
顶部:80px;
z指数:1;
}
#img10{
位置:绝对位置;
左:90px;
顶部:90px;
z指数:1;
}
#img11{
位置:绝对位置;
左:100px;
顶部:100px;
z指数:1;
}
#img12{
位置:绝对位置;
左:110像素;
顶部:110px;
z指数:1;
}
#img13{
位置:绝对位置;
左:120px;
顶部:120px;
z指数:1;
}
#img14{
位置:绝对位置;
左:130像素;
顶部:130像素;
z指数:1;
}
#img15{
位置:绝对位置;
左:140像素;
顶部:140px;
z指数:1;
}

您把脚本放错地方了。并更改
document.getElementById(id).style.zIndex=“2”
id.style.zIndex=“2”

单击的函数(id){
document.getElementById(“img1”).style.zIndex=“1”;
document.getElementById(“img2”).style.zIndex=“1”;
document.getElementById(“img3”).style.zIndex=“1”;
document.getElementById(“img4”).s