运行 ❯
获取你
自己的
网站
×
更改方向
保存代码
更改主题,暗色/亮色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript String Methods</h1> <p>Replace all occurrences of "Microsoft" with "W3Schools" in the paragraph below:</p> <button onclick="myFunction()">Try it</button> <p id="demo">Please visit Microsoft and Microsoft!</p> <script> function myFunction() { let text = document.getElementById("demo").innerHTML; document.getElementById("demo").innerHTML = text.replace(/Microsoft/g,"W3Schools"); } </script> </body> </html>