Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <p>Replace "Microsoft" with "W3Schools" in the paragraph below:</p> <button onclick="myFunction()">Try it</button> <p id="demo">Please visit Microsoft!</p> <script> function myFunction() { var str = document.getElementById("demo").innerHTML; var txt = str.replace("Microsoft", "W3Schools"); document.getElementById("demo").innerHTML = txt; } </script> </body> </html>
Result: