Created
January 17, 2018 08:44
-
-
Save thomasorten/2c6cf3baec2fce066840b9f88c957533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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