gpt4 book ai didi

JQuery:animate() 在 IE 中无法按预期工作

转载 作者:行者123 更新时间:2023-12-03 23:00:26 25 4
gpt4 key购买 nike

我对这个 IE 7 感到疯狂...

==> hhttp://neu.emergent-innovation.com/

为什么以下功能在 IE 7 中不起作用,但在 Firefox 中却完美?动画功能有错误吗?

function accordion_starting_page(){
// hide all elements except the first one
$('#FCE-Inhalt02-ContentWrapper .FCE-Fade:not(:first)').css("height", "0").hide();
$('#FCE-Inhalt02-ContentWrapper .FCE-Fade:first').addClass("isVisible");

$('div.FCE-Title').click(function(){

// if user clicks on an already opened element => do nothing
if (parseFloat($(this).next('.FCE-Fade').css("height")) > 0) {
return false;
}

var toHide = $(this).siblings('.FCE-Fade.isVisible');

toHide.removeClass("isVisible");

// close all opened siblings
toHide.animate({"height": "0", "display": "none"}, 1000);

$(this).next('.FCE-Fade').addClass("isVisible").animate({"height" : "200"}, 1000);

return false;
});
}

非常感谢您的帮助...

<小时/>

非常感谢,这些都是很好的提示!不幸的是,它仍然不起作用......

问题是 IE 显示两个容器的内容,直到动画结束...Firefox 的行为正确...我认为这是“溢出:隐藏”的问题 - 但这并没有改变任何东西。

我已经尝试过 Accordion 插件,但它的行为完全相同......

最佳答案

我在 animate 函数中遇到了类似的问题,当它显示来自核心 jQuery 库的错误时,我感到很惊讶。不过 jQuery 很好,但你需要迎合 IE。

在 IE 中对元素的任何属性进行动画处理时,您需要确保在 CSS 中存在要更改的属性的起点。这也适用于 Safari。

例如,将 div 不断向左移动,

JQuery:

var re = /px/;
var currentLeft = $("#mydiv").css('left').replace(re,'') - 0;
$("#mydiv").css('left',(currentLeft-20)+'px');

CSS:

#mydiv { position: absolute;    top: 0;    left: 0; }

如果您不放置在左侧和顶部的起始位置,IE 最终将抛出错误。

希望这有帮助

关于JQuery:animate() 在 IE 中无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/333911/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com