Answers for "javascript echo variable in html"

5

html use js variable as text

<h1>"My number: " <span id="myText"></span></h1>

<script>

	//You can use an IIFE (Immediately Invoked Function Expression)
	(() => {
  		var number = "123";
		document.getElementById("myText").innerHTML = number;
	})();
</script>
Posted by: Guest on September-29-2020
3

how to print to screen in javascript

console.log("Hello World!");
alert("Console has been updated.");
Posted by: Guest on October-23-2020
3

how to print a line in javascript

console.log("Your line would be here")//Prints a line on the console 
alert("Your message here")//Raises an alert
Posted by: Guest on April-27-2020

Browse Popular Code Answers by Language