title: program to Roll a dice with picture instead number using javascript
body: <p>I am trying to print out images on the dice, instead of just the number. But when i am using document.write, it just opens a new tab, and shows the picture. What should i use to print it out, with the button i have?    </p>
  
  <pre><code>&lt;div id="roll-dice"&gt;
      &lt;button type="button" value="Trow dice" onclick="rolldice()"&gt;Roll dice&lt;/button&gt;
      &lt;span id="roll-result"&gt;&lt;/span&gt;
  &lt;/div&gt;
  
  var rollResult = Math.floor(Math.random() * 6) + 1;
          if (rollResult == 1) document.write('&lt;img src="1.jpg"&gt;');
  else if (rollResult == 2) document.write('&lt;img src="2.jpg"&gt;');
  else if (rollResult == 3) document.write('&lt;img src="3.jpg"&gt;');
  else if (rollResult == 4) document.write('&lt;img src="4.jpg"&gt;');
  else if (rollResult == 5) document.write('&lt;img src="5.jpg"&gt;');
  else  document.write('&lt;img src="6.jpg"&gt;');
  </code></pre>