以下のコードは、見出しと段落をすべて自動的に削除し、問題の画像だけを読み込みます。テキストを置き換えるのではなく、イメージを追加します。なぜこれが起こっているのですか?画像を追加するのではなく画像に置き換えます
<!DOCTYPE html>
<html>
<body>
<h1>My Web Page</h1>
<p>My paragraph.</p>
<p id="flipDisplay"></p>
<button onclick="display()">Flip the Coin!</button>
<script>
function coinFlip() {
return (Math.floor(Math.random() * 2) == 0);
}
function display() {
if (coinFlip()) {
document.write('<img src="./tflip.png">');
} else {
document.write('<img src="./ctflip.png">');
}
}
</script>
<!--<a><img src=javacript:flip></a> -->
</body>
</html>
'.html()'について – JanLeeYu