Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created December 9, 2016 03:18
Show Gist options
  • Save dengjonathan/04ac1be1a576f8566617ac2603a59627 to your computer and use it in GitHub Desktop.
Save dengjonathan/04ac1be1a576f8566617ac2603a59627 to your computer and use it in GitHub Desktop.
Vanilla JS
<!DOCTYPE html>
<html>
<head>
<title>Vanilla JS MVC</title>
</head>
<body>
<div class="counter">
<button id="up">+</button>
<p id="count">0</p>
<button id="down">-</button>
</div>
<script>
(function() {
const $count = document.getElementById('count');
const $up = document.getElementById('up');
const $down = document.getElementById('down');
$up.onclick = () => $count.innerHTML = parseInt($count.innerHTML) + 1;
$down.onclick = () => $count.innerHTML = parseInt($count.innerHTML) - 1;
})()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment