Advertisement
informaticage

aoclel loop js html

Apr 6th, 2021
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.79 KB | None | 0 0
  1. <html lang="en">
  2.   <head>
  3.     <meta charset="UTF-8" />
  4.     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6.     <title>LEL</title>
  7.   </head>
  8.   <body>
  9.     <section id="items"></section>
  10.  
  11.     <script>
  12.       const items = [
  13.         { title: "Titolo 1", price: 12 },
  14.         { title: "Titolo 2", price: 14 },
  15.         { title: "Titolo 3", price: 17 },
  16.       ];
  17.       const itemsHtml = items.map(
  18.         (item) =>
  19.           `<section>
  20.             <header>${item.title}</header>
  21.             <main>${item.price}</main>
  22.           <section>`
  23.       );
  24.  
  25.       const itemsContainer = document.querySelector("#items");
  26.       itemsContainer.innerHTML = itemsHtml.join('<br>');
  27.     </script>
  28.   </body>
  29. </html>
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement