Skip to content

Instantly share code, notes, and snippets.

@travis23
Last active September 9, 2020 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travis23/b4d2bb3f9cbbd1667021bce0a685f608 to your computer and use it in GitHub Desktop.
Save travis23/b4d2bb3f9cbbd1667021bce0a685f608 to your computer and use it in GitHub Desktop.
[Display Javascript Variable on HTML Page] #javascript #html
<!-- See https://stackoverflow.com/questions/40858456/how-to-display-a-javascript-var-in-html-body -->
<html>
<head>
<script>
function displayNumber(number) {
document.getElementById("someID").innerHTML = number.toString();
}
</script>
</head>
<body onload="displayNumber(42)">
<p><span id="headCount"></span></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment