Advertisement
Guest User

lista

a guest
Jan 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. ############# index.html ##############
  2. <html>
  3. <head>
  4. <link rel="stylesheet" href="style.css">
  5. </head>
  6. <body>
  7. <input id="input" type="text">
  8. <button onclick="dodaj()">Button</button>
  9. <div id="main" class="main_class"></div>
  10. </body>
  11. <script src="script.js"></script>
  12. </html>
  13.  
  14. ############ script.js #############
  15. const maindiv = document.getElementById("main");
  16. const listaul = document.createElement('ul');
  17. listaul.id = "listaul";
  18. maindiv.appendChild(listaul);
  19.  
  20.  
  21. function dodaj()
  22. {
  23. const li = document.createElement("li");
  24. li.className = "lista";
  25. listaul.appendChild(li);
  26. const input = document.getElementById("input");
  27. li.innerHTML = input.value;
  28. input.value = "";
  29. }
  30. ############# style.css ##############
  31. .lista
  32. {
  33. display:flex;
  34. align-items:center;
  35. justify-content: center;
  36. background-color:lightblue;
  37. width:200px;
  38. height:10px;
  39. padding:3px;
  40. margin:3px;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement