Created
January 28, 2018 14:34
-
-
Save thomasorten/74b58c4b5d8d0a359648fffd419969e4 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> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body class="fancy"> | |
<h1>Thomas sin hjemmeside</h1> | |
<h2>0</h2> | |
<input type="submit" value="Minus" id="minus"> | |
<input type="submit" value="Pluss" id="pluss" class="fancy"> | |
<img src="https://i.giphy.com/media/107Xn5YFUzKyac/200w.gif" alt=""> | |
<script> | |
// DRY = Don't repeat yourself | |
var element = document.getElementsByTagName("h2")[0]; | |
var tekst = "thomas " + "orten"; // Blir til "thomas orten" | |
var tekst = "thomas " - "orten"; // Funker ikke | |
var tall = "1" + "1"; // Blir til "11" | |
var tall = "1" - "1"; // Må bli 0 | |
function minusFunksjon() { | |
element.innerHTML = parseInt(element.innerHTML)-1; | |
//element.innerHTML = --element.innerHTML; | |
} | |
function plussFunksjon() { | |
element.innerHTML = parseInt(element.innerHTML)+1; | |
//element.innerHTML = ++element.innerHTML; | |
} | |
document.getElementById("minus").onclick = minusFunksjon; | |
document.getElementById("pluss").onclick = plussFunksjon; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment