0

replace() 関数を使用して上記のコードを調整し、次のテキストを表示しようとしています: Is this all?! innerHTML に追加されたテキストを保持しながら

 <p id="str">Click the button for a surprise.</p>
 <form action="#">
 <input type="submit" onclick="myFunction()" value="Enter">
 </form>

 function myFunction(){
 document.getElementById('str').innerHTML = "Is this all there is?";
 str.replace(str, "Is this all?!")
 }
4

3 に答える 3

0
function myFunction(){
  var currentText = document.getElementById('str').innerHTML;
  var resultText = currentText + " Is this all?!";
  document.getElementById('str').innerHTML = resultText;
} 
于 2013-11-13T15:36:13.247 に答える