Browse Source

Exercise 2: add a self-rmoving "you were here" paragraph on click.

Frederic G. MARAND 8 years ago
parent
commit
9d08235892
1 changed files with 7 additions and 0 deletions
  1. 7 0
      Chapter 5/05.js

+ 7 - 0
Chapter 5/05.js

@@ -54,4 +54,11 @@ $(document).ready(function () {
       .text($clonedCopy.text())
       .prependTo($parentParagraph);
   });
+
+  $('a[href="#top"]').click(function (event) {
+    var $youWereHere = $(this).after($('<p>You were here</p>')).next('p');
+    setTimeout(function () {
+      $youWereHere.remove();
+    }, 3000)
+  });
 });