Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <head>
  4. <style>
  5. .active{
  6. text-decoration: underline;
  7. font-weight: bold;
  8. }
  9. </style>
  10. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  11. <script src="javascript.js"></script>
  12. <script>
  13. $(document).ready(function(){
  14. var i = 1;
  15. $("li").click(function(){oznaci(this);});
  16. $("#dodaj").click(function(){
  17. var novi = document.createElement("li");
  18. novi.innerHTML = $("#novi_element").val();
  19. novi.classList.add("list-group-item");
  20. $(novi).click(function(){oznaci(this);});
  21. $("ul").append(novi);
  22. shrani();
  23. });
  24.  
  25. $("#dodaj_v_tabelo").click(function(){
  26. var opravilo = $("#oznacen").val();
  27. var vtabelo = $("#nov_vnos").val();
  28. var novit = "<tr><td>" + i + "</td><td>" + vtabelo + "</td><td>" + opravilo + "</td><td>BLABLA</td></tr>";
  29. $("table tbody").append(novit);
  30. i = i+1;
  31. });
  32. $("#brisi_iz_tabele").click(function(){
  33. var opravilo = $("#oznacen").val();
  34. var vtabelo = $("#nov_vnos").val();
  35. var novit = "<tr><td>" + i + "</td><td>" + vtabelo + "</td><td>" + opravilo + "</td><td>BLABLA</td></tr>";
  36. $("table tbody").append(novit);
  37. i = i+1;
  38. });
  39.  
  40. $("#brisi").click(function(){
  41. $(".active").remove();
  42. shrani();
  43. });
  44. });
  45. function oznaci(kliknjen){
  46. $(".active").removeClass("active");
  47. $(kliknjen).toggleClass("active");
  48. $(kliknjen).attr('id', 'oznacen');
  49. console.log("#oznacen").val();
  50. }
  51. </script>
  52. <title></title>
  53. </head>
  54. <body>
  55. <div class="kategorije">
  56. <input type="text" name="kategorija" id="novi_element">
  57. <button type="button" id="dodaj">Dodaj</button>
  58. <button type="button" id="brisi">BriΕ‘i</button> <br>
  59. <ul>
  60. <li class="list-group-item">Vaje</li>
  61. <li class="list-group-item">Treningi</li>
  62. <li class="list-group-item">Projekti</li>
  63. </ul>
  64. </div>
  65. <div class="tabela">
  66. <input type="text" name="kategorija" id="nov_vnos">
  67. <button type="button" id="dodaj_v_tabelo">Dodaj</button>
  68. <table>
  69. <thead>
  70. <tr>
  71. <th class="table-group-item">#</th>
  72. <th class="table-group-item">Opis</th>
  73. <th class="table-group-item">Kategorija</th>
  74. <th class="table-group-item">Datum vnosa</th>
  75. </tr>
  76. </thead>
  77. <tbody>
  78. </tbody>
  79. </table>
  80. <button type="button" id="brisi-iz-tabele">BriΕ‘i</button>
  81. </div>
  82. </body>
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement