Skip to content

Instantly share code, notes, and snippets.

@neel1998
Created January 24, 2020 10:24
Show Gist options
  • Save neel1998/bc4acd8443a982f031f6f9b88d28a273 to your computer and use it in GitHub Desktop.
Save neel1998/bc4acd8443a982f031f6f9b88d28a273 to your computer and use it in GitHub Desktop.
Counter JS
<!DOCTYPE html>
<html>
<head>
<script>
function counter(){
var cText = document.getElementById("demo");
var count = parseInt(cText.innerHTML);
count = count + 1;
document.getElementById("demo").innerHTML = count;
}
</script>
</head>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">1</p>
<button type="button" onclick="counter()">Click Me!</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment