Ver Fonte

Listing 4.12: toggling visibility with fadeToggle().

Frederic G. MARAND há 8 anos atrás
pai
commit
725725bf6d
1 ficheiros alterados com 5 adições e 5 exclusões
  1. 5 5
      Chapter 4/04.js

+ 5 - 5
Chapter 4/04.js

@@ -22,12 +22,12 @@ $(document).ready(function () {
   $firstPara.hide();
   $('a.more').click(function (event) {
     event.preventDefault();
-    if ($firstPara.is(':hidden')) {
-      $firstPara.fadeIn('slow');
-      $(this).text('read less');
+    $firstPara.slideToggle('slow');
+    var $link = $(this);
+    if ($link.text() == 'read more') {
+      $link.text('read less');
     } else {
-      $firstPara.fadeOut('slow');
-      $(this).text('read more');
+      $link.text('read more');
     }
   });
 });