<center><p id="demo" style="color:black;"></p></center>
<script>
window.onload = function() {
typeWriter();
};
var i =0;
var txt = "Would it be ok if I wrote you a rhyme? would it be ok if I opened my heart? Would it be ok if I took on the part Of being your man and showed you a view, One that only a real man could do? Would it be ok if I could make you smile? Would it be alright to look in your eyes? Would it be alright to never tell lies? Would it be alright to find a way? Would it be alright to long for the day To pull you close and whisper in your ear And tell you our feelings are nothing to fear? Would it be ok if I took some of your time? Would it be ok if I wrote you a rhyme? To tell you there is nothing I would rather do Than spend my whole life loving only you... ";
var txt1= '';
var speed = 100;
function typeWriter() {
if (i < txt.length) {
document.getElementById("demo").innerHTML += txt.charAt(i);
document.getElementById("demo").innerHTML += txt1.charAt(i);
i++;
setTimeout(typeWriter, speed);
}
}
</script>
私は次の行のすべての文章を詩として印刷したいと思っています...!しかし、私はそれをすることはできません助けて喜んで誰もがある場合はください!私は彼/彼女を感謝します おかげでアドバンス私は/ n、/ r/nを試してみましたが、失敗しました。私は試しましたが、失敗しました。
私はあなたが(String.prototype.splitを見てみましょう示唆D)https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split – Azadrum
また、 '
'タグを使用して、異なる行のテキストを区切ることができます。 – MysterX
あなたは私に何を言っているのか正確なコードを教えてくれますか? –