How Do I Replace/Change The Heading Text Inside <h1></h1>, Using Javascript?

noobprogrammer picture noobprogrammer · Aug 20, 2013 · Viewed 19.1k times · Source

How do I change/replace the text: "Hello" using javascript to say "Goodbye" instead?

<h1 class="titlearea win-type-ellipsis" id="title">
     <span class="pagetitle" >
            Hello
     </span>
</h1>

Answer

Mithun Satheesh picture Mithun Satheesh · Aug 20, 2013
document.getElementsByClassName("pagetitle")[0].innerHTML = "Goodbye";

Here is a working fiddle.