I'm struggling to assign the value of a String Variable to a specific element in the DOM within a particular div.
Let's use an example: game=TEN
document.getElementById("game").innerHTML=game;
The issue is that it does not write to:
<div id="game"></div>
The problem lies with the following code. I have a script where, at the end of it, I can document.write(game) and everything works fine, but I'm unable to write it to the div? Perhaps I am approaching this incorrectly.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
...
</script>
<div id="game" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:16px">hello</divЮ
</body>
</html>