Procházet zdrojové kódy

Listing 3.12: targeting this.

Frederic G. MARAND před 9 roky
rodič
revize
c489dab013
1 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 4 2
      Chapter 3/03.js

+ 4 - 2
Chapter 3/03.js

@@ -5,8 +5,10 @@ $(document).ready(function () {
     .hover(
       function () { $(this).addClass('hover'); },
       function () { $(this).removeClass('hover'); })
-    .click(function () {
-      $('#switcher button').toggleClass('hidden');
+    .click(function (event) {
+      if (event.target === this) {
+        $('#switcher button').toggleClass('hidden');
+      }
     });
 
     $('#switcher-default').addClass('selected');