Question Detail

How can replace any word from jquery

3 years ago Views 727 Visit Post Reply

Thread Reply

Lokesh Gupta

- 3 years ago

<p id="demo">Visit Microsoft!</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    var str = document.getElementById("demo").innerHTML; 
    var res = str.replace("Microsoft", "W3Schools");
    document.getElementById("demo").innerHTML = res;
}
</script>