我是JavaScript新手。我在一个网站上工作,我正在尝试使用按钮更改一组框架的z索引。我不太能让它工作。
到目前为止,这就是我所拥有的。
function changeZIndex(i,id) {
document.getElementById(id).style.zIndex=i;
}在身体里
<A HREF="#" onclick='changeZIndex(1,'aboutus')'><IMG NAME="one" SRC="button1.bmp"></A>
<A HREF="#" onclick='changeZIndex(1,'contactus')'><IMG NAME="two" SRC="button2.bmp"></A>是的,我意识到这可能是有史以来最愚蠢的问题,答案也很明显。这是我第一次写JavaScript,所以请对我手下留情!:3
发布于 2011-05-21 11:53:41
确保您的引号正确转义。尝试:
<a href="#" onclick="changeZIndex(1,'aboutus')"><img name="one" src="button1.bmp"></a>
<a href="#" onclick="changeZIndex(1,'contactus')"><img name="two" src="button2.bmp"></a>请注意onclick前后的双引号
发布于 2011-05-21 11:53:18
您的引号错误-查看语法突出显示:
<A HREF="#" onclick='changeZIndex(1,'aboutus')'><IMG NAME="one" SRC="button1.bmp"></A>
<A HREF="#" onclick='changeZIndex(1,'contactus')'><IMG NAME="two" SRC="button2.bmp"></A>你可以这样做:
<A HREF="#" onclick="changeZIndex(1,'aboutus')"><IMG NAME="one" SRC="button1.bmp"></A>
<A HREF="#" onclick="changeZIndex(1,'contactus')"><IMG NAME="two" SRC="button2.bmp"></A>发布于 2011-05-21 13:01:27
看看你的语录
然后,如果您将'aboutus‘的zindex更改为1,不要忘记将'contactus’的zindex更改为0。
否则,如果您将'contactus‘的zindex更改为1,不要忘记将'aboutus’的zindex更改为0。
<A HREF="#" onclick="changeZIndex(1,'aboutus');changeZIndex(0,'contactus');"><IMG NAME="one" SRC="button1.bmp"></A>
<A HREF="#" onclick="changeZIndex(1,'contactus');changeZIndex(0,'aboutus');"><IMG NAME="two" SRC="button2.bmp"></A>https://stackoverflow.com/questions/6079474
复制相似问题