Replace the contents of an HTML element (HTML + JavaScript)

Setting the value of innerHTML lets you easily replace the existing contents of an element with new content.

For example, you can erase the entire contents of a document by clearing the contents of the document’s body attribute:

document.body.innerHTML = "";

This example fetches the document’s current HTML markup and replaces the "<"characters with the HTML entity "&lt;", thereby essentially converting the HTML into raw text. This is then wrapped in a .documentElement.innerHTML = "<pre>" + document.documentElement.innerHTML.replace(/</g,"&lt;") + "</pre>";

Replace the existing content of all the elements of the desired class with a new content:

<script>
    var i;

    for (i = 0; i < document.getElementsByClassName("button").length; i++) {

        if (document.getElementsByClassName('button')[i].innerHTML == 'Continue Reading →'){

        var yourHTML = 'MORE INFO / PHOTOS →';
        document.getElementsByClassName('button')[i].innerHTML = yourHTML;

        }
    }
</script>