How to display JavaScript variables in an HTML page without document.write?

JavascriptObject Oriented ProgrammingFront End Technology

Use Element.innerHTML in JavaScript to display JavaScript variables in an HTML page without document.write.

You can try to work through the following code snippet −

var $myName = document.querySelector('.name');
var $jsValue = document.querySelector('.jsValue');

$myName.addEventListener('input', function(event){
   $jsValue.innerHTML = $myName.value;
}, false);
raja
Published on 01-Mar-2018 10:11:40
Advertisements