Просмотр исходного кода

Listing 4.16: animate() with an increment.

Frederic G. MARAND 8 лет назад
Родитель
Сommit
ab2f9556fe
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      Chapter 4/04.js

+ 11 - 0
Chapter 4/04.js

@@ -33,4 +33,15 @@ $(document).ready(function () {
       $link.text('read more');
     }
   });
+
+  $('div.label').click(function () {
+    var paraWidth = $('div.speech p').outerWidth();
+    var $switcher = $(this).parent();
+    var switcherWidth = $switcher.outerWidth();
+    $switcher.animate({
+      borderWidth: '5px',
+      left: paraWidth - switcherWidth,
+      height: '+=20px'
+    }, 'slow');
+  });
 });