我遇到了JQuery拒绝设置元素的z-index的问题。不仅仅是一定数量,而是任何金额!我在通过JQuery构建元素时设置它(但这只是在附加代码中),然后尝试在交换图像的函数中再次设置它。但是当它获得第9次迭代时,它应该将z-index设置为0,而不是,并且juts忽略它。我坐下来尝试各种不同的事情无济于事,如果有人能帮忙,那就太好了。
所有这些的代码都在此页面上: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调用。
提前致谢。
詹姆斯
答案 0 :(得分:0)
看一下你的脚本文件......
您的z-index设置逻辑正常工作(在Chrome Dev中单独测试),看起来更像是逻辑所在的函数永远不会被调用(周围的断点从未被触发过。)
我建议您使用Chrome的内置调试工具仔细查看您的脚本。 https://developer.chrome.com/extensions/tut_debugging.html#debug
[如果有帮助请注明。 :)]