In the example below, we create a variable called userName and assign the value "John1234" to it.
Then we "output" the value inside an HTML paragraph with id="test"
Then we "output" the value inside an HTML paragraph with id="test"
<!DOCTYPE html>
<html>
<body>
<div id="test"></div>
<script>
var userName = "John1234";
document.getElementById("test").innerHTML = userName;
</script>
</body>
</html>
Most Helpful This Week
How to get selected text from a select box using jQuery?
JavaScript HTML5 Validation for name and email field
jQuery check if an element is visible or hidden
JavaScript convert string variable in boolean using Regex
jQuery show input text inside div after on click event
How to change the height of Textarea on click?