Created
November 10, 2012 04:42
-
-
Save cecilemuller/4049939 to your computer and use it in GitHub Desktop.
jQuery: replace HTML contents with a smooth height animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$.fn.replace_html = function(html){ | |
return this.each(function(){ | |
var el = $(this); | |
el.stop(true, true, false); | |
var finish = {width: this.style.width, height: this.style.height}; | |
var cur = {width: el.width() + "px", height: el.height() + "px"}; | |
el.html(html); | |
var next = {width: el.width() + "px", height: el.height() + "px"}; | |
el.css(cur).animate(next, 300, function(){el.css(finish);}); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment