Created
February 3, 2021 14:39
-
-
Save sandhikagalih/db7737d63c9081095b0dc71f2347a280 to your computer and use it in GitHub Desktop.
This file contains hidden or 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="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<input type="text" id="angka" value="1"> | |
<button type="button" id="tambah">+</button> | |
<button type="button" id="kurang">-</button> | |
<script> | |
const angka = document.querySelector('#angka'); | |
const tambah = document.querySelector('#tambah'); | |
const kurang = document.querySelector('#kurang'); | |
// tombol tambah diklik | |
tambah.addEventListener('click', function() { | |
angka.value++; | |
}) | |
// tombol kurang diklik | |
kurang.addEventListener('click', function() { | |
angka.value--; | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment