Skip to content

Instantly share code, notes, and snippets.

@thomasorten
Created January 17, 2018 08:44
Show Gist options
  • Save thomasorten/2c6cf3baec2fce066840b9f88c957533 to your computer and use it in GitHub Desktop.
Save thomasorten/2c6cf3baec2fce066840b9f88c957533 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>En flott liste</h1>
<ul id="liste">
</ul>
<input type="text" id="felt1">
<input type="submit" id="knapp">
<script>
function leggTilListeElement() {
var minListe = document.getElementById("liste");
var listeElement = document.createElement("li");
var tekst = document.getElementById("felt1").value;
if (tekst !== "") {
listeElement.innerHTML = tekst;
minListe.appendChild(listeElement);
}
}
document.getElementById("knapp").onclick = leggTilListeElement;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment