IE中的jQuery fadeIn + fadeOut吗? [英] jQuery fadeIn + fadeOut in IE?

查看:101
本文介绍了IE中的jQuery fadeIn + fadeOut吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jQuery的g淡淡淡入和淡出效果方面遇到问题,无法在IE(6 + 7 + 8)中正常工作.该脚本在FF和safari中可以很好地工作(可以很好地褪色),但是在IE中,它只能显示/隐藏-完全没有褪色效果.

I am having a problem with gtetting fadeIn and fadeOut effect of jQuery to work properly in IE (6+7+8). The script works fine in FF and safari (fading nicely) but in IE it just shows/hides - no fading effect at all.

有什么想法吗?

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

它得到的href属性只是持有一个表示ul长度位置的数字值.

The href attribute that it is getting is simply holding a numeric value representing the position in the ul li length.

推荐答案

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

I had the same issue and used the code below (from the link posted by Q8-coder above). It works well but I still had some issues. I noticed that using fadeTo on a container element which had children with relative or absolute positioning didn't work in IE8. The parent would fade but all the children elements with positive or relative positioning would remain in view. The only way to get around it was to select the container element and all it's children using jQuery and then apply fadeTo all of them.

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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆