I am making a hunger games simulation and this is my code:
console.log(data);
document.getElementById("playarea").innerHTML = data;
console.log(document.getElementById("playarea").innerHTML);
When I log the variable data to the console it gives me the following result,
<img src='img/fight.png'><br />
You grabbed a loaf of bread out of the crate, the girl from 9 comes to you for a fight.
<br />
<button onclick=fight('You grabbed a loaf of bread out of the crate, the girl from 9
comes to you for a fight.','','',4,1,2)>
Punch in the head
</button><br />
<button onclick=fight('You grabbed a loaf of bread out of the crate, the girl from 9
comes to you for a fight.','','',4,1,2)>Punch in the chest</button><br />
When I log the innerHTML of playarea I get
<img src="img/fight.png"><br>
You grabbed a loaf of bread out of the crate, the girl from 9 comes to you for a fight.
<br>
<button onclick="fight('You" grabbed="" a="" loaf="" of="" bread="" out="" the=""
crate,="" girl="" from="" 9="" comes="" to="" you="" for=""
fight.','','',4,1,2)="">
Punch in the head
</button><br>
<button onclick="fight('You" grabbed="" a="" loaf="" of="" bread="" out="" the=""
crate,="" girl="" from="" 9="" comes="" to="" you="" for=""
fight.','','',4,1,2)="">
Punch in the chest
</button><br>
In the onclick it is separating each word and treating them like variables.
How can I make the innerHTML to be the same as data variable?