javascript - 你能在IE8中用JS改变z-index吗

标签 javascript jquery internet-explorer z-index

非常简单的例子: http://jsbin.com/ohude

单击按钮 1,“hello2”文本 p 应将 z-index 更改为 89。单击按钮 2,z-index 应再次更改。这在 Firebug 中很明显。但它在 IE8 中不起作用。

有人可以确认吗?

谢谢。

最佳答案

我没有 IE8,也不知道 jQuery 代码。

您是要更改查看的文本还是仅更改 z-index?如果 z-index 和查看的文本,在 Safari 中是不行的。

为了我的测试,我将您原来的 jQuery 样式函数更改为:

  1. 提醒您的原始更改(注意 style.zIndex,而不是 z-index);和
  2. 然后更改文本 nodeValue 以反射(reflect) z-index 的变化。

首先,我将您的 css 更改为 css('zIndex','89') 以查看是否改变了结果。 无论是 css('zIndex'...) 还是 css('z-index'...),对我都有效

正如我所说,我不懂 jQuery。但是在 IE8 中测试以下代码片段后,如果它不起作用,请尝试将 css arg 更改为 'zIndex',只是为了笑。

测试:

$('#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

关于javascript - 你能在IE8中用JS改变z-index吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/890191/

相关文章:

javascript - 在初始 View 调用中从 Angular JS 中的 Spring MVC 获取数据

javascript - 部署我的 meteor 应用程序时出现问题

javascript - 需要将街景小人放置在 map 的中心

javascript - 处理双击时的第二个 mousedown 事件

html - 目标 IE 9 及以下版本并带有条件注释

jQuery :nth-child not working in IE

javascript - 无需测试即可检测脚本延迟支持

javascript - Mousemove offset 弄乱了悬停效果

jQuery ajax 不调用 Servlet

html - 在 Internet Explorer 中使所有文本 EXCEPT <input> 都不可选择?