how to display javascript variable value in html page
<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>// Plain Javascript Example
var $jsName = document.querySelector('.name');
var $jsValue = document.querySelector('.jsValue');
$jsName.addEventListener('input', function(event){
$jsValue.innerHTML = $jsName.value;
}, false);
// JQuery example
var $jqName = $('.name');
var $jqValue = $('.jqValue');
$jqName.on('input', function(event){
$jqValue.html($jqName.val());
});var name="kieran";
document.getElementById("output").innerHTML=name;
and the html code would be:
<p id="output"></p>
Also in JavaScript:
- javascript get random number
- add all elements in array javascript
- node js sendgrid
- javascript for loop that prints 10 times
- javascript base64url decode
- onfocus jquery
- json in listview flutter
- mongodb install err npm
- react native components
- get messages by id discord.js
- fetch download blob file
- javascript detect mobile or desktop
- Process event is emitted right before Node Process crashes and exits:
- react cloud foundry nginx proxy
- ajax status code
- javascript ajax post send an object
- angularjs left xx characters
- how will it look when there is a container inside a a row bootstrap
- color text react native
- javascript dictionary
- json parsing techniques in api
- mongoose virtual populate not working
- check data type in js
- how to proxy enable in server nodejs