Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 22nd, 2012  |  syntax: None  |  size: 1.35 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Removing elements and then adding them again
  2. <div id="content">
  3.     <div class="tile"></div>
  4.     <div class="tile"></div>
  5.     <div class="tile"></div>
  6. </div>
  7.        
  8. $(".tile").fadeOut( showTileSpeed, function() {
  9.     $(this).remove();
  10. });
  11.  
  12.  
  13. tiles[tileIndex]();// function adding .tiles to my #content
  14.  
  15. $(".tile").first().fadeIn(showTileSpeed, function showNext() {
  16.     $(this).next(".tile").fadeIn(showTileSpeed, showNext);
  17. });
  18.        
  19. var $tiles = $(".tile").fadeOut(showTileSpeed, function() {
  20.     $(this).remove();
  21. });
  22.  
  23. $.when($tiles).done(function() {      // <-- after all animations do this
  24.     tiles[tileIndex]();
  25.  
  26.     $(".tile").first().fadeIn(showTileSpeed, function showNext() {
  27.         $(this).next(".tile").fadeIn(showTileSpeed, showNext);
  28.     });
  29. });
  30.        
  31. var $tiles = $(".tile").fadeOut(showTileSpeed);
  32.  
  33. $.when($tiles).done(function() {
  34.     $tiles.remove();
  35.     tiles[tileIndex]();
  36.  
  37.     $(".tile").first().fadeIn(showTileSpeed, function showNext() {
  38.         $(this).next(".tile").fadeIn(showTileSpeed, showNext);
  39.     });
  40. });
  41.        
  42. $(document).ready(function() {
  43.     $(".tile").fadeOut( showTileSpeed, function() {
  44.         $(this).remove();
  45.         tiles[tileIndex]();// function adding .tiles to my #content
  46.         $(".tile").first().fadeIn(showTileSpeed, function showNext() {
  47.             $(this).next(".tile").fadeIn(showTileSpeed, showNext);
  48.         });
  49.     });
  50. });