Advertisement
-Annie-

01.Summary

Jul 19th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Summary</title>
  6.     <script src="jquery-1.10.2.js"></script>
  7. </head>
  8. <body>
  9.  
  10. <div class="wrapper">
  11.     <div id="content">
  12.         <p><strong>The Theodor Pallady Museum </strong>is a museum situated in one of the oldest surviving merchant
  13.             houses in Bucharest, Romania. It <strong>includes many works by the </strong>well-known Romanian <strong>painter
  14.                 Theodor Pallady</strong>, as well as a number of European and Oriental furniture pieces.</p>
  15.     </div>
  16.     <input type="button" id="generate" value="Generate Summary"/>
  17. </div>
  18. <script>
  19.     $(() => generateSummary('#generate'));
  20. </script>
  21. <script>
  22.     function generateSummary(selector) {
  23.         $(selector).on('click', function () {
  24.             let strongText = $('#content strong').text();
  25.             createSummary(strongText);
  26.         });
  27.  
  28.         function createSummary(strongText) {
  29.             let summary = $('<div>');
  30.             summary.attr('id', 'summary')
  31.             let heading = $('<h2>').text('Summary');
  32.             let paragraph = $('<p>').text(strongText);
  33.  
  34.             summary.append(heading);
  35.             summary.append(paragraph);
  36.             let parent = $('#content').parent();
  37.             parent.append(summary);
  38.         }
  39.     }
  40. </script>
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement