Skip to content

Instantly share code, notes, and snippets.

@ralphholzmann
Created April 27, 2010 23:32
Show Gist options
  • Save ralphholzmann/381495 to your computer and use it in GitHub Desktop.
Save ralphholzmann/381495 to your computer and use it in GitHub Desktop.
$.fn.fadeSwap = function(content, callback) {
// Return each ...
return this.each( function() {
// Save reference to this
var $this = $(this);
// Fade to 0
$this.animate({
'opacity' : '0'
}, function() {
// Switchout content, fade back to 1
$this.html(content).animate({
'opacity' : '1'
}, function() {
// Remove filter (IE cleartype fix)
if ($.browser.msie) {
this.style.removeAttribute('filter');
}
// Run callback if it exists
(callback || $.noop).apply(this);
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment