gpt4 book ai didi

IE 中的 jQuery fadeIn + fadeOut?

转载 作者:行者123 更新时间:2023-12-01 07:02:31 25 4
gpt4 key购买 nike

我在设置 jQuery 的 fadeIn 和 fadeOut 效果以使其在 IE (6+7+8) 中正常工作时遇到问题。该脚本在 FF 和 safari 中运行良好(淡入淡出效果很好),但在 IE 中它只是显示/隐藏 - 根本没有淡入淡出效果。

有什么想法吗?

$(".myclass ul li:eq(" + $(this).attr("href") + ")").fadeIn(5000); 

它获取的 href 属性只是保存一个表示 ul li 长度中位置的数值。

最佳答案

我遇到了同样的问题并使用了下面的代码(来自上面 Q8-coder 发布的链接)。它运作良好,但我仍然遇到一些问题。我注意到,在具有相对或绝对定位子元素的容器元素上使用 fadeTo 在 IE8 中不起作用。父元素将消失,但所有具有正向或相对定位的子元素将保留在 View 中。解决这个问题的唯一方法是使用 jQuery 选择容器元素及其所有子元素,然后对所有元素应用 fadeTo。

jQuery.fn.fadeIn = function(speed, callback) { 
return this.animate({opacity: 'show'}, speed, function() {
if (jQuery.browser.msie)
this.style.removeAttribute('filter');
if (jQuery.isFunction(callback))
callback();
});
};

jQuery.fn.fadeOut = function(speed, callback) {
return this.animate({opacity: 'hide'}, speed, function() {
if (jQuery.browser.msie)
this.style.removeAttribute('filter');
if (jQuery.isFunction(callback))
callback();
});
};

jQuery.fn.fadeTo = function(speed,to,callback) {
return this.animate({opacity: to}, speed, function() {
if (to == 1 && jQuery.browser.msie)
this.style.removeAttribute('filter');
if (jQuery.isFunction(callback))
callback();
});
};

关于IE 中的 jQuery fadeIn + fadeOut?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1941356/

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