Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE中的Z索引:li元素在其上时消失_Javascript_Html_Css_Internet Explorer_Z Index - Fatal编程技术网

Javascript IE中的Z索引:li元素在其上时消失

Javascript IE中的Z索引:li元素在其上时消失,javascript,html,css,internet-explorer,z-index,Javascript,Html,Css,Internet Explorer,Z Index,在JS代码中,我声明当在垂直菜单中的LI元素上结束时,所有LI元素都会得到样式:z-index:5,除了当前的over LI元素和class=selected的LI元素,样式是:z-index:10。 在chrome、FF中效果很好,但在IE中,当我跳过菜单中的li元素时,它就消失了 以下是JS代码: var mainMenu_li = document.getElementById('mainMenu').getElementsByTagName('li'); for(i = 0; i &l

在JS代码中,我声明当在垂直菜单中的LI元素上结束时,所有LI元素都会得到样式:z-index:5,除了当前的over LI元素和class=selected的LI元素,样式是:z-index:10。 在chrome、FF中效果很好,但在IE中,当我跳过菜单中的li元素时,它就消失了

以下是JS代码:

var mainMenu_li = document.getElementById('mainMenu').getElementsByTagName('li');

for(i = 0; i < mainMenu_li.length; i++)
    if(mainMenu_li[i].className != "selected")
        mainMenu_li[i].style.zIndex = '5';

$('#' + curObjID).parent().css('z-index','10');

你能帮我什么忙吗?

首先阅读本系列文章:

如果您试图在IE7中使用z索引-它有问题-请尝试在没有z索引的情况下基于堆栈构建菜单。例如-不带悬停位置:静态,带悬停位置:相对

同时尝试设置无悬停位置:相对;不带z索引且悬停位置:相对;z指数:2


如果您将样式放在类中,并通过类使用jquery进行操作,效果会更好:addClass'class'和removeClass'class'

无法帮助您查看HTML。另外,请参阅:抱歉,我忘记写入链接…我没有声明z-index:0。。。。