Ver Fonte

Listing 3.23: simulating click with trigger().

Frederic G. MARAND há 9 anos atrás
pai
commit
e70c4f73a6
1 ficheiros alterados com 2 adições e 1 exclusões
  1. 2 1
      Chapter 3/03.js

+ 2 - 1
Chapter 3/03.js

@@ -18,11 +18,12 @@ $(document).ready(function () {
   };
 
   $('#switcher').on('click', toggleSwitcher);
+  $('#switcher').trigger('click');
 
   $('#switcher button').click(function () {
     $('#switcher').off('click', toggleSwitcher);
 
-    if (this.id == 'switcher-default') {
+    if (this.id === 'switcher-default') {
       $('#switcher').on('click', toggleSwitcher);
     }