Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title></title>
- </head>
- <body>
- <ul id="lista">
- <li>Ponedeljak</li>
- <li>Utorak</li>
- <li>Sreda</li>
- <li>Cetvrtak</li>
- <li>Petak</li>
- <li>Subota</li>
- <li>Nedelja</li>
- </ul>
- <input id="Text1" type="text" placeholder="Unesi tekst" />
- <br /><br />
- <input id="Text2" type="text" placeholder="Unesi broj"/>
- <br /><br />
- <input id="Button1" type="button" value="Dodaj" onclick="dodaj()" />
- <input id="Button2" type="button" value="Procitaj" onclick="procitaj()" />
- <input id="Button3" type="button" value="Obrisi" onclick="obrisi()" />
- <p id="p1"></p>
- <script src="js.js"></script>
- </body>
- </html>
- function dodaj()
- {
- text1 = document.getElementById("Text1");
- var lista = document.getElementById("lista");
- var li = document.createElement("li");
- li.appendChild(document.createTextNode(text1.value));
- lista.appendChild(li);
- }
- function procitaj()
- {
- tekst = document.getElementById("p1");
- broj = document.getElementById("Text2");
- lista = document.getElementById("lista");
- tekst.innerHTML = lista.getElementsByTagName("li")[broj.value].innerHTML;
- }
- function obrisi()
- {
- broj = document.getElementById("Text2");
- lista = document.getElementById("lista");
- lista.removeChild(lista.childNodes[broj.value]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement