0

我遇到了 JQuery 拒绝设置元素的 z-index 的问题。不仅仅是一定数量,而是任何数量!我在通过 JQuery 构建元素时设置它(但这只是在附加代码中),然后尝试在交换图像的函数中再次设置它。但是当它进行第 9 次迭代时,它应该将 z-index 设置为 0,而不会,并且会忽略它。我已经坐下来尝试了各种不同的事情,但都无济于事,如果有人可以提供帮助,那就太好了。

所有这些的代码都在这个页面上:http: //www.prideoftameside.co.uk/default-redesign.htm

您需要查看的具体部分是:

function loadImage(number) {
 if (number) {
    imagecount = number;
}

if (imagecount == 1) {
    $('#introimages > img:nth-child(1)').css({'z-index' : 9 });
}

$('#introimages > img:nth-child(' + imagecount + ')').animate({'opacity' : 0 }, 2000)

$('#introimages > img:nth-child(' + (imagecount + 1) + ')').css({'opacity' : 1 });

if (imagecount == 9) {
    $('#introimages > img:nth-child(1)').css({'opacity' : 1, 'z-index' : 0 });
    imagecount = 0;
}

imagecount += 1;
}

通过第 246 行的 SetInterval 调用。

提前致谢。

詹姆士

4

1 回答 1

0

看了一眼你的脚本文件...

您的 z-index 设置逻辑工作正常(在 Chrome Dev 中单独测试),看起来更像是逻辑所在的函数永远不会被调用(周围的断点从未被触发。)

我建议使用 Chrome 的内置调试工具仔细查看您的脚本。 https://developer.chrome.com/extensions/tut_debugging.html#debug

[如果有帮助,请标记。:)]

于 2012-10-23T16:19:19.463 回答