Animating with Opacity in jQuery Animate

Sam Deering

When using opacity to fade in or fade out over time using jQuery.animate, you’ll run into font rendering issues with all versions of Internet Explorer.

This leaves you with 2 options:

Use jQuery’s opacity(‘show’) or opacity(‘hide’) shortcut properties which handle IE’s shortcomings, or Set the filter css property to ‘none’ once you’ve completed your animation Obviously, if you’re fading something in from being completely hidden, option 1 makes sense, otherwise you’ve got no choice but to use option 2.

I came across this as I had font rendering issues for Cruiseabout in tabs content that was being caused by my use of opacity in FCL.TABS. As a result, I’ve patched FCL.TABS to use opacity’s “show” and “hide” properties instead of “0? and “1? and the problem has been fixed.

Broken code

$tabContent.css('opacity', 0);
$tabContent.animate(
{
opacity: 1
}, 350);

Fixed code

$tabContent.css('opacity', 'hide');
$tabContent.animate(
{
opacity: 'show'
}, 350);

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.