Created
March 31, 2017 02:16
-
-
Save jl91/5e6ee9663d1244114e020960ccee3b66 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 lang="pt-br"> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<input type="text" readonly="readonly" name="numbers"> | |
<button id="plus" onclick="plus()">+</button> | |
<button id="minus" onclick="minus()">-</button> | |
<script> | |
var counter = 0; | |
var numbers = document.getElementsByName('numbers')[0]; | |
numbers.value = counter; | |
function plus() { | |
numbers.value = (parseFloat(numbers.value) + 0.5); | |
} | |
function minus() { | |
var minimumValue = 0; | |
var currentValue = parseFloat(numbers.value) - 0.5; | |
if (currentValue < minimumValue) { | |
currentValue = minimumValue; | |
} | |
numbers.value = currentValue; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment