Browse Source

Exercise 2: hide/reveal chapters on title click.

Frederic G. MARAND 8 years ago
parent
commit
fad4611f1a
1 changed files with 8 additions and 1 deletions
  1. 8 1
      Chapter 3/03.js

+ 8 - 1
Chapter 3/03.js

@@ -29,7 +29,7 @@ $(document).ready(function () {
 
     $('#switcher').off('click', toggleSwitcher);
 
-    if (className == 'default') {
+    if (className === 'default') {
       $('#switcher').on('click', toggleSwitcher);
     }
   };
@@ -61,7 +61,14 @@ $(document).ready(function () {
     }
   });
 
+  // Exercise 1.
   $('.author').click(function () {
     $(this).toggleClass('selected');
   });
+
+  // Exercise 2.
+  $('.chapter-title').dblclick(function () {
+    $(this).siblings().toggleClass('hidden');
+  });
+
 });