编辑下面的代码:【加编码】
<html> <body> <p>Click the button to replace "Microsoft" with "自强学堂" in the paragraph below:</p> <p id="demo">Visit Microsoft!</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var str=document.getElementById("demo").innerHTML; var n=str.replace("Microsoft","自强学堂"); document.getElementById("demo").innerHTML=n; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂