JSFiddle - React, Tailwind, and code Playground
by Rufuus06
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Replace()</title>
</head>
<body>
<h2>Replace():</h2>
<p>Cambia un String por otro que le indiquemos.</p>
<button onclick="myFunction()">
Cambialo
</button>
<p id="exp1">Hello Mundo!</p>
<p id="exp"></p>
</body>
</html>
JavaScript
function myFunction()
{
var str = document.getElementById("exp1").innerHTML;
var txt = str.replace("Hello", "Hola");
document.getElementById("exp").innerHTML = txt;
}