Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. var template = "<p>I've replaced the button<br>and in a very smooth<br>fashion!</p>";
  2.  
  3. var doAnimation = function(e) {
  4. var parent = $(this).parent();
  5. var oldHeight = parent.height();
  6.  
  7. $(this).fadeOut(400, function() {
  8. this.remove();
  9.  
  10. var paragraph = $(template).appendTo(parent);
  11. var newHeight = parent.height();
  12.  
  13. paragraph.hide().fadeIn();
  14. parent.height(oldHeight).animate({height: newHeight});
  15. });
  16. }
  17.  
  18. $(document).on('click', 'button', doAnimation);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement