index.html:13 Uncaught TypeError: Cannot set property 'innerHTML' of null
the code run fine but why am i getting the above error?
i already tried running the script before and after the html element, still getting error.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
var txt1 = "some text else";
</script>
<script type="text/javascript">
var txt = document.write("some text here");
document.getElementById('ii').innerHTML = txt;
</script>
</head>
<body>
<p id="ii"></p>
<script>
document.write(txt1);
</script>
</body>
</html>