125
rated 0 times
[
131]
[
6]
/ answers: 1 / hits: 23249
/ 10 Years ago, fri, december 19, 2014, 12:00:00
Following is my code.
<html>
<head>
<script>
var x = 5;
var y = 6;
var z = x + y;
document.getElementById(add).innerHTML = z;
</script>
</head>
<body>
<h1>Demo</h1>
<div id=demo>Addition of 5 and 6 is <span id=add></span>
</div>
</body>
</html>
And when I am trying to display the value of z in (span add) I am getting following error.
TypeError: document.getElementById(...) is null
Please help me.
More From » javascript