Using jQuery to fadeIn and fadeOut 24bit PNG images in Internet Explorer you may get black rings. If you’re using CSS images, a I’ve written how to fix black rings here. However if you use images in the HTML like this:
<ul id="ImageList"> <li><img src="24-bit-1.png" alt="img1" id="img1"/></li> <li><img src="24-bit-2.png" alt="img2"/></li> <li><img src="24-bit-3.png" alt="img3"/></li> </ul>
Use need to use this jQuery fix instead:
if( $.browser.msie && parseInt($.browser.version) < 9 ) {
$('#ImageList >li > img').each(function(){
$(this).attr('width', $(this).width());
$(this).attr('height', $(this).height());
$(this).css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='"+$(this).attr('src')+"')");
$(this).attr('src', '/images/Transparent.gif');
});
}
It works by replacing the image with a filter, which supports alpha transparency. It uses a 1×1 Transparent.gif, and checks if the browser is IE8 or less.
Note! you must fade out the parent for it work:
$('#img1').parent().fadeOut();
Tags: IE, javascript, jQuery, PNG