很简单的例子: http://jsbin.com/ohude
单击button1,'hello2'文本p应将z-index更改为89.单击button2,z-index应再次更改。这在萤火虫中很明显。但它在IE8中没有做插孔。
有人可以确认吗?
感谢。
答案 0 :(得分:2)
我没有IE8,也不知道jQuery代码。
您是尝试更改查看的文本还是仅更改z-index?如果查看了z-index和文本,那么在Safari中就不行了。
对于我的测试,我将原始的jQuery样式函数更改为:
首先,我将你的css更改为css('zIndex','89')以查看是否改变了结果。 无论哪种方式css('zIndex'...)或css('z-index'...),为我工作。
正如我所说,我不知道jQuery。但是在IE8中测试了以下片段之后,如果它不起作用,请尝试将css arg更改为'zIndex',只是为了咧嘴笑。
TEST:
$('#click').click(function () {
$('#hello').css('z-index','89');
var pid = document.getElementById('hello');
alert('pid.style.zIndex: ' + pid.style.zIndex);
pid.firstChild.nodeValue = "Hello2 " + pid.style.zIndex;
});
$('#click2').click(function () {
$('#hello').css('z-index','10');
var pid = document.getElementById('hello');
alert('pid.style.zIndex: ' + pid.style.zIndex);
pid.firstChild.nodeValue = "Hello2 " + pid.style.zIndex;
});
});
很抱歉弄乱你的JQuery代码。 :d
答案 1 :(得分:1)
您尝试在测试页面中设置z-index的元素没有设置CSS“位置”,因此更改z-index实际上不起作用。
添加位置:相对;或者位置:绝对的; CSS属性应该允许你设置他们的z-indix。