views:

538

answers:

4

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.

Any ideas?

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

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

+1  A: 

try this workaround.

Anwar Chandra
Same result - still no fading. Although it looks like it is now somewhat fading the text with the <li> but not the <img> :-s
cJockey
please include an explanation rather than just linking
TM
what version of jQuery?
Anwar Chandra
The newst right from their own site
cJockey
A: 

Try this:

$(".myclass ul li:eq(" + $(this).attr("href") + ")").hide().fadeIn(5000);
Derek Illchuk
Did not do anything i'm afraid :-(
cJockey
A: 

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();  
    }); 
};
Nick Lowman
All that's doing by the way is overriding the jQuery functions so you just need to stick them in your javascript file along with your other code.
Nick Lowman
all the elements inside the <li> container are actually posistioned absolute, including the picture. How would i go about at appliing fade to the <li> and all the elements inside it?
cJockey
$(".myclass ul li:eq(" + $(this).attr("href") + ")").children().hide().fadeIn("slow"); did the trick
cJockey
Nice one. Glad you got it sorted in the end.
Nick Lowman